geopython / OWSLib

OWSLib is a Python package for client programming with Open Geospatial Consortium (OGC) web service (hence OWS) interface standards, and their related content models.
https://owslib.readthedocs.io
BSD 3-Clause "New" or "Revised" License
392 stars 278 forks source link

Add offline testing to CI #952

Closed geographika closed 2 weeks ago

geographika commented 4 weeks ago

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 commented 4 weeks ago

Coverage Status

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

geographika commented 3 weeks ago

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.