Make Delphi-Epidata tests Pytest compatible. #371
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
While discussing docker testing with @dshemetov and playing around with pytest a bit, realized that supporting it might not be too difficult and went ahead and did this.
This change allows for pytest to be run on the delphi-epidata unit tests and integration tests. They still must be run through the docker image since the docker replicates the file structure on the actual automation server which isn't the same as how things are locally. I'm not sure theres a simple way such that both docker and nondocker can be run at the same time.
These changes are backwards compatible with py3tester, so you can use whichever test suite you prefer. I didn't actually change any test syntax (e.g. assertEqual(a,b) -> assert a==b) since pytest can use unittest syntax.
Pytest can be run with
docker run --rm delphi_python pytest repos/delphi/delphi-epidata/tests/
or
docker run -it --rm delphi_python pytest repos/delphi/delphi-epidata/tests/ --pdb
,which will put you into an interactive pdb shell in the docker container if a test fails (which was my primary motivation for getting this to work).
(similar commands for integrations folder but with /integrations/ instead of /tests/)
I've verified that both pytest and py3tester conduct 64 passing unit tests and 36 passing integration tests (same as main). pytest raises 2-3 warnings from src/acquisition/covid_hosp/common/test_utils, which contains a class called TestUtils that has test helper functions but is not a test itself. pytest just warns that it's not considering that class a test, which is correct.
Summary of changes:
@krivard for review.