-
Notifications
You must be signed in to change notification settings - Fork 397
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
github: add workflow for unit tests #73
Conversation
e0f90ef
to
7b49eba
Compare
This also adds a |
.github/workflows/tests.yaml
Outdated
- name: Test with pytest | ||
run: | | ||
pip install pytest | ||
pytest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The existing tests (under src/dailyai/tests/test_*
) use unittest
-- will this workflow run them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, pytest
just automatically looks for tests. You can see how it runs them in the CI step below. But I'll be more explicit though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah yeah I just tried it, but it seems to miss the doctests. (7 tests with pytest vs 11 with unittest)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
.github/workflows/tests.yaml
Outdated
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
pip install -r requirements-full.txt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a way to extract the requirements from the toml file for testing? Otherwise we'll need to keep it in sync with requirements-full.txt
which seems like it might be error-prone.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see. Let me see what I can do...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I have removed requirements-full.txt
and we are just building the project now which forces to install the dependencies in the toml file.
aa9d875
to
b14ac29
Compare
.github/workflows/tests.yaml
Outdated
- name: Test with pytest | ||
run: | | ||
pip install pytest | ||
pytest src/dailyai/tests/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a load_tests
function in test_aggregators.py
that loads the aggregators
module and then runs a DocTestSuite
against that module. It doesn't seem to be picked up by pytest. (which is why pytest is reporting fewer tests than unittest). Not sure if there's a way to address that directly with pytest or if we should run unittest.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see. How do you run that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the record, the way to run it with unitest is:
python -m unittest -v src/dailyai/tests/test_*
However, pytest
doesn't like load_tests
and since we are only loading the doctests, we can just do:
pytest --doctest-modules --ignore-glob="*to_be_updated*" src/dailyai
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
b14ac29
to
65430c6
Compare
65430c6
to
cc05429
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thanks for figuring that out!
No description provided.