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

Add offline testing to CI #952

Merged
merged 4 commits into from
Nov 7, 2024
Merged

Conversation

geographika
Copy link
Contributor

This pull request makes use of the https://github.com/miketheman/pytest-socket/ plugin to check the test suite runs without network access. Relates to #951.

There is no simple way to mark doctests as requiring online access, or to disable the --doctest-modules flag from the command line, so I have manually deselected the 3 tests that require network access in the main.yml file.

To ensure the test suite passes additional @pytest.mark.online have been added to tests requiring network access.

tox.ini was modified to put options on separate lines to improve readibility.

@coveralls
Copy link

coveralls commented Oct 27, 2024

Coverage Status

coverage: 60.149% (-0.007%) from 60.156%
when pulling a8ade74 on geographika:offline
into ae98c20 on geopython:master.

mgorny and others added 2 commits November 1, 2024 13:45
Move the OSHFixtures class into a pytest fixture to defer initializing
it (and therefore accessing the Internet) until the relevant test
functions are called.  This makes it possible for `pytest.mark.online`
to correctly skip them.  It also avoids initializing the fixtures class
multiple times -- now it should be initialized once per session.

While at it, move the global functions into the OSHFixtures class.  It
would need to access the class members anyway, and this seems cleaner
than passing its instance explicitly.
Move network-accessing fixtures init into a pytest fixture
@geographika
Copy link
Contributor Author

From comments in the merged pull request from @mgorny (to avoid these details being lost):

Move the OSHFixtures class into a pytest fixture to defer initializing it (and therefore accessing the Internet) until the relevant test functions are called. This makes it possible for pytest.mark.online to correctly skip them. It also avoids initializing the fixtures class multiple times -- now it should be initialized once per session.

While at it, move the global functions into the OSHFixtures class. It would need to access the class members anyway, and this seems cleaner than passing its instance explicitly.

@geographika geographika merged commit 40cfa45 into geopython:master Nov 7, 2024
4 checks passed
@geographika geographika deleted the offline branch November 7, 2024 17:37
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.

3 participants