-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconftest.py
57 lines (47 loc) · 1.22 KB
/
conftest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import os
import platform
import sys
import importlib
import socket
import functools
import time
import pytest
import jaraco.functools
from jaraco.context import ExceptionTrap
missing = ExceptionTrap(ImportError).raises
@missing
def pywin32_missing():
importlib.import_module('win32service')
collect_ignore = (
[
'jaraco/net/devices/linux.py',
'jaraco/net/devices/win32.py',
'jaraco/net/devices/darwin.py',
]
+ [
# modules only import on Windows
'jaraco/net/dns.py',
]
* pywin32_missing()
+ [
# ping test has different exception on older Pythons
'jaraco/net/icmp.py',
]
* (sys.version_info < (3, 10))
)
@pytest.fixture(autouse=True)
def retry_ntp_query(request):
"""
ntp.query is flaky (by design), so be resilient during tests.
"""
if not request.node.name.endswith('net.ntp.query'):
return
retry = jaraco.functools.retry(
retries=4,
trap=socket.timeout,
cleanup=functools.partial(time.sleep, 4),
)
globs = request.node.dtest.globs
globs['query'] = retry(globs['query'])
if os.environ.get('GITHUB_ACTIONS') and platform.system != 'Linux':
pytest.skip("Test is flaky")