Skip to content

Commit 40cfa45

Browse files
geographikamgorny
andauthored
Add offline testing to CI (#952)
* Setup offline testing in CI * Remove option * Move network-accessing fixtures init into a pytest fixture 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. --------- Co-authored-by: Michał Górny <mgorny@gentoo.org>
1 parent cdd92cd commit 40cfa45

File tree

5 files changed

+276
-262
lines changed

5 files changed

+276
-262
lines changed

.github/workflows/main.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ jobs:
2727
pip3 install -r docs/requirements.txt
2828
- name: run tests ⚙️
2929
run: python3 -m pytest
30+
- name: run tests in offline mode
31+
if: matrix.python-version == '3.10'
32+
run: |
33+
python3 -m pytest \
34+
-m "not online" \
35+
--disable-socket \
36+
--deselect="tests/doctests/wcs_thredds.txt::wcs_thredds.txt" \
37+
--deselect="tests/doctests/wfs_MapServerWFSCapabilities.txt::wfs_MapServerWFSCapabilities.txt" \
38+
--deselect="tests/doctests/wms_geoserver_mass_gis.txt::wms_geoserver_mass_gis.txt"
3039
- name: run coveralls ⚙️
3140
run: coveralls
3241
- name: build docs 🏗️

requirements-dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
flake8
33
pytest
44
pytest-cov
5+
pytest-socket
56
Pillow
67
tox
78
twine

tests/test_csw_geonetwork.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def test_csw_geonetwork():
1919

2020
SERVICE_URL3 = 'https://metawal.wallonie.be/geonetwork/srv/eng/csw'
2121

22+
@pytest.mark.online
2223
@pytest.mark.skipif(not service_ok(SERVICE_URL3),
2324
reason='service is unreachable')
2425
@pytest.mark.parametrize("esn_in", ['full', 'summary'])

0 commit comments

Comments
 (0)