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

github: add workflow for unit tests #73

Merged
merged 1 commit into from
Mar 19, 2024
Merged

Conversation

aconchillo
Copy link
Contributor

No description provided.

@aconchillo aconchillo force-pushed the github-unittests-workflow branch 9 times, most recently from e0f90ef to 7b49eba Compare March 18, 2024 22:48
@aconchillo
Copy link
Contributor Author

This also adds a requirements-full.txt.

- name: Test with pytest
run: |
pip install pytest
pytest
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-full.txt
Copy link
Contributor

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.

Copy link
Contributor Author

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...

Copy link
Contributor Author

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.

@aconchillo aconchillo force-pushed the github-unittests-workflow branch 2 times, most recently from aa9d875 to b14ac29 Compare March 19, 2024 18:32
- name: Test with pytest
run: |
pip install pytest
pytest src/dailyai/tests/
Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor Author

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@aconchillo aconchillo force-pushed the github-unittests-workflow branch from b14ac29 to 65430c6 Compare March 19, 2024 18:37
@aconchillo aconchillo force-pushed the github-unittests-workflow branch from 65430c6 to cc05429 Compare March 19, 2024 18:51
Copy link
Contributor

@Moishe Moishe left a 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!

@aconchillo aconchillo merged commit 5fc21a7 into main Mar 19, 2024
2 checks passed
@aconchillo aconchillo deleted the github-unittests-workflow branch October 23, 2024 20:53
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