Skip to content

Commit 7665312

Browse files
bdrungs0undt3ch
authored andcommitted
Fix test_has_local_network if local network is not present
During Debian package build on the official Debian builders, the `skip_if_no_local_network` will fail. This will cause `test_has_local_network` to fail. So mock `socket.socket` to ensure that `test_has_local_network` will work regardless of the environment it is executed it. Signed-off-by: Benjamin Drung <[email protected]>
1 parent 4863a56 commit 7665312

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

tests/functional/test_requires_network.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,13 @@ def test_one():
2323
assert True
2424
"""
2525
)
26-
res = pytester.runpytest()
27-
res.assert_outcomes(passed=1)
26+
with mock.patch(
27+
"pytestskipmarkers.utils.ports.get_unused_localhost_port",
28+
side_effect=[ports.get_unused_localhost_port() for n in range(10)],
29+
):
30+
with mock.patch("pytestskipmarkers.utils.markers.socket.socket"):
31+
res = pytester.runpytest()
32+
res.assert_outcomes(passed=1)
2833
res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*")
2934

3035

tests/unit/utils/markers/test_skip_if_no_remote_network.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414

1515

1616
def test_has_remote_network():
17-
assert markers.skip_if_no_remote_network() is None
17+
with mock.patch("pytestskipmarkers.utils.markers.socket.socket"):
18+
assert markers.skip_if_no_remote_network() is None
1819

1920

2021
def test_no_remote_network():

0 commit comments

Comments
 (0)