Colocate tests w/ objects tested; switch from unittest to pytest#89
Colocate tests w/ objects tested; switch from unittest to pytest#89
Conversation
| run: pip install -r requirements.txt | ||
| run: | | ||
| python -m venv --upgrade-deps .venv | ||
| source .venv/bin/activate |
There was a problem hiding this comment.
using a venv here to emulate how we suggest people set up in the README.
| - 'examples/**' | ||
| branches: | ||
| - main | ||
| pull_request: |
There was a problem hiding this comment.
This will now run the tests after the PR was merged, which is a good failsafe for the production branch (main)
| 2. Create a new branch to contain your changes. | ||
| 2. `add`, `commit`, and `push` your changes to this branch. | ||
| 3. Create a pull request (PR). See more information on submitting a PR request below. | ||
| 1. Fork `main` branch. |
There was a problem hiding this comment.
Cloning does not work because outside people do not have write permission. One has to fork to contribute, which is standard practice for open-source repos.
| 5. Submit your pull request and add reviewers. | ||
|
|
||
| 1. If necessary, please **write your own unit tests** and place them near the code being tested. High-level tests, such as integration or example tests can be placed in the top-level "tests" folder. | ||
| 2. Verify that all tests are passed by running `python -m pytest .`. |
There was a problem hiding this comment.
using pytest instead of unittest
|
|
||
| # data | ||
| raw_data | ||
| data |
There was a problem hiding this comment.
I added this because that is where the tutorial and example notebooks often look. We could also rename all of those hardcoded paths to "raw_data" and not add a "data" field here.
|
I think this all looks great! Breaking the inference/prior code into individual files is a big change but I do think it is better for testing, and doesn't change the user's interface. That said, is there any reason I'm not so much asking you to do this, but more so if there is any reason not to do this. |
Yup, I think so. Best to have consistent formatting everywhere. I can follow-up with this later. I made issue #90 for now. |
Makes sense! Thanks for making the issue. |
Issues resolved
#83
Description
I made three structural changes
unittestdependency in favor ofpytest.Pytest is a more flexible framework, and will allow us to extend the testing environment beyond what unittest allows.
This structure trades file complexity for directory complexity, which has a few upsides.
*_test.pyformat.Notes for reviewer
Reviewing commit-by-commit will probably be easier than the full diffs, since much of the changes were programatic.
The third from last commit updates tolerances on two tests. These tests would fail on
mainas well if you change the torch manual seed. We should consider setting up a reproducible-but-random sequence of seeds, aka "fuzz testing", for CI tests to give these inference methods more coverage.