python-zeep icon indicating copy to clipboard operation
python-zeep copied to clipboard

Add a network pytest mark for tests that use the network

Open mcepl opened this issue 1 year ago • 0 comments

Sometimes it's useful to have the tests that use the network marked so they can be skipped easily when we know the network is not available.

This is useful for example on SUSE and openSUSE's build servers. When building our packages the network is disabled so we can assure reproducible builds (among other benefits). With this mark, it's easier to skip tests that can not succeed.

[   15s] =================================== FAILURES ===================================
[   15s] _______________________ TestSqliteCache.test_has_expired _______________________
[   15s] 
[   15s] self = <tests.test_cache.TestSqliteCache object at 0x7facc43ae250>
[   15s] tmpdir = local('/tmp/pytest-of-abuild/pytest-0/test_has_expired0')
[   15s] 
[   15s]     def test_has_expired(self, tmpdir):
[   15s]         c = cache.SqliteCache(path=tmpdir.join("sqlite.cache.db").strpath)
[   15s]         c.add("http://tests.python-zeep.org/example.wsdl", b"content")
[   15s]     
[   15s]         freeze_dt = datetime.datetime.utcnow() + datetime.timedelta(seconds=7200)
[   15s] >       with freezegun.freeze_time(freeze_dt):
[   15s] 
[   15s] tests/test_cache.py:43: 
[   15s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
[   15s] /usr/lib/python3.9/site-packages/freezegun/api.py:634: in __enter__
[   15s]     return self.start()
[   15s] /usr/lib/python3.9/site-packages/freezegun/api.py:739: in start
[   15s]     event_loop = asyncio.new_event_loop()
[   15s] /usr/lib64/python3.9/asyncio/events.py:761: in new_event_loop
[   15s]     return get_event_loop_policy().new_event_loop()
[   15s] /usr/lib64/python3.9/asyncio/events.py:659: in new_event_loop
[   15s]     return self._loop_factory()
[   15s] /usr/lib64/python3.9/asyncio/unix_events.py:54: in __init__
[   15s]     super().__init__(selector)
[   15s] /usr/lib64/python3.9/asyncio/selector_events.py:56: in __init__
[   15s]     self._make_self_pipe()
[   15s] /usr/lib64/python3.9/asyncio/selector_events.py:103: in _make_self_pipe
[   15s]     self._ssock, self._csock = socket.socketpair()
[   15s] /usr/lib64/python3.9/socket.py:607: in socketpair
[   15s]     a = socket(family, type, proto, a.detach())
[   15s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
[   15s] 
[   15s] args = (<AddressFamily.AF_UNIX: 1>, <SocketKind.SOCK_STREAM: 1>, 0, 12)
[   15s] kwargs = {}
[   15s] 
[   15s]     def func(*args, **kwargs):
[   15s] >       pytest.fail("External connections not allowed during tests.")
[   15s] E       Failed: External connections not allowed during tests.
[   15s] 
[   15s] tests/conftest.py:14: Failed

Complete build log with versions of all packages used and steps taken to reproduce.

mcepl avatar Dec 19 '23 13:12 mcepl