Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change directory more safely in unit tests #51

Merged
merged 2 commits into from
Mar 2, 2023
Merged

Change directory more safely in unit tests #51

merged 2 commits into from
Mar 2, 2023

Conversation

Iain-S
Copy link
Collaborator

@Iain-S Iain-S commented Mar 2, 2023

A slight improvement over the previous system since we now save the starting directory in setUp and return to it in tearDown. Previously, we did chdir('../..') in tearDown, which could go wrong if something unexpected happened in setUp or if an extra chdir() was used in the test functions themselves.

Some improvements that could be added here or in a future PR

  • Reduce duplication by moving the examples/ and workspace/ directories to the test utils module and making them Final.
  • run_psql() presumes that it is being called from the repo root directory. This doesn't feel good as it then matters which order you do the setUp calls in. Is there a way we can remove this reliance on the current working directory to run the db setup scripts with psql?

@Iain-S
Copy link
Collaborator Author

Iain-S commented Mar 2, 2023

Update:

  • I have added a commit that changes how run_psql() works slightly. It can now be called from any location and takes a Path to the .dmp file to be run.

@Iain-S Iain-S requested a review from mhauru March 2, 2023 11:06
@mhauru mhauru mentioned this pull request Mar 2, 2023
@mhauru mhauru merged commit bee1f8e into main Mar 2, 2023
@Iain-S Iain-S deleted the test-chdir branch March 2, 2023 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants