Skip to content

Conversation

@chinandrew
Copy link
Contributor

@chinandrew chinandrew commented Jan 12, 2021

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:

  • Import necessary functions/classes for all tests
  • Add init files to each dir with tests in it, with commands to append the post-dockerfile copy operation path for imports
  • Update dev guides stating this is possible now

@krivard for review.

@chinandrew chinandrew changed the title Make Delphi-Epidata unit tests Pytest compatible. Make Delphi-Epidata tests Pytest compatible. Jan 13, 2021
Copy link
Contributor

@krivard krivard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

xlnt

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