Closed mgorny closed 2 weeks ago
@mgorny can you try annotating the failing tests with @pytest.mark.online
and see if the test suite then passes?
FWIU initializing OSHFixtures.systems_api
is failing in global scope, therefore preventing the file from being imported, and possibly some more of the initializations below are going to fail as well. To fix this, I suppose the relevant bits would need to be initialized lazily or otherwise locally, and I'm not really sure how many tests would remain — or if any would.
As I've suspected, all the *_api
variable inits cause Internet accesses, and when I remove all of them, all the tests that aren't skipped — fail.
@mgorny - #952 runs the tests in offline mode (ignoring those that require network access). Do these changes get the test suite to pass on your setup?
I'm afraid it doesn't. The test collection still fails on calls being made in the global scope. I think there are only two ways to prevent this from happening: either don't issue any network calls in global scope, or modify the pytest collect hook to skip the file entirely when Internet isn't available. I think the former should be easier, and could achieve very similar behavior by moving the class into a session-scope pytest fixture. I can try making a pull request if you'd like.
@mgorny - yes, a pull request would be appreciated. I guess the calls are made before the pytest plugin disables sockets. Attempting to create a GitHub Action and disabling network access did not seem to be a viable option (at least in terms of complexity and maintenance).
I've opened https://github.com/geographika/OWSLib/pull/1 that modifies your PR to do the fixture approach.
Resolved with #952
When running the test suite in a container isolated from the Internet, with
-m "not online"
option, it started failing in 0.32.0 release: