Skip to content

Commit 07fcad9

Browse files
committed
Skip network flag
1 parent 647ad96 commit 07fcad9

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

docs/development.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,13 @@ under 20 seconds on an modern workstation:
529529
$ python3 -m pytest --skip-slow
530530
```
531531

532+
If you have an agent running the tests in a sandboxed environment, you may need to
533+
skip tests thsat require network access or FIFOs:
534+
535+
```bash
536+
$ python3 -m pytest --skip-network
537+
```
538+
532539
If you have a lot of failing tests it can be useful to have a shorter summary
533540
of the failing lines:
534541

python/tests/conftest.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ def pytest_addoption(parser):
5252
parser.addoption(
5353
"--skip-slow", action="store_true", default=False, help="Skip slow tests"
5454
)
55+
parser.addoption(
56+
"--skip-network",
57+
action="store_true",
58+
default=False,
59+
help="Skip network/FIFO tests",
60+
)
5561
parser.addoption(
5662
"--overwrite-expected-visualizations",
5763
action="store_true",
@@ -71,6 +77,7 @@ def pytest_configure(config):
7177
Add docs on the "slow" marker
7278
"""
7379
config.addinivalue_line("markers", "slow: mark test as slow to run")
80+
config.addinivalue_line("markers", "network: mark test as using network/FIFO")
7481

7582

7683
def pytest_collection_modifyitems(config, items):
@@ -79,6 +86,11 @@ def pytest_collection_modifyitems(config, items):
7986
for item in items:
8087
if "slow" in item.keywords:
8188
item.add_marker(skip_slow)
89+
if config.getoption("--skip-network"):
90+
skip_network = pytest.mark.skip(reason="--skip-network specified")
91+
for item in items:
92+
if "network" in item.keywords:
93+
item.add_marker(skip_network)
8294

8395

8496
@fixture

python/tests/test_fileobj.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ def stream(fifo, ts_list):
242242
assert ts.tables == ts_out.tables
243243

244244

245+
@pytest.mark.network
245246
@pytest.mark.skipif(IS_WINDOWS, reason="No FIFOs on Windows")
246247
@pytest.mark.skipif(IS_OSX, reason="FIFO flakey on OS X, issue #1170")
247248
class TestFIFO:
@@ -286,6 +287,7 @@ def server_process(q):
286287
server.serve_forever()
287288

288289

290+
@pytest.mark.network
289291
@pytest.mark.skipif(IS_WINDOWS or IS_OSX, reason="Errors on systems without proper fds")
290292
class TestSocket:
291293
@fixture
@@ -339,6 +341,7 @@ def write_and_read_from_fifo(fifo_path, file_path, expected_exception, error_tex
339341
read_process.join(timeout=3)
340342

341343

344+
@pytest.mark.network
342345
@pytest.mark.skipif(IS_WINDOWS, reason="No FIFOs on Windows")
343346
class TestBadStream:
344347
def test_bad_stream(self, tmp_path):

0 commit comments

Comments
 (0)