From e645104656fda22f4c0c2b3d9841ed792b1e7103 Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Mon, 8 Nov 2021 13:01:27 +0000 Subject: Configure pytest to enable/disable integration tests --- conftest.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'conftest.py') diff --git a/conftest.py b/conftest.py index d5e851fe..c4e4fec5 100644 --- a/conftest.py +++ b/conftest.py @@ -1,5 +1,7 @@ import sys +import pytest + pytest_plugins = 'setuptools.tests.fixtures' @@ -9,6 +11,18 @@ def pytest_addoption(parser): "--package_name", action="append", default=[], help="list of package_name to pass to test functions", ) + parser.addoption( + "--integration", action="store_true", default=False, + help="run integration tests (only)" + ) + + +def pytest_configure(config): + config.addinivalue_line("markers", "integration: indicate integration tests") + + if config.option.integration: + # Assume unit tests and flake already run + config.option.flake8 = False collect_ignore = [ @@ -27,3 +41,13 @@ collect_ignore = [ if sys.version_info < (3, 6): collect_ignore.append('docs/conf.py') # uses f-strings collect_ignore.append('pavement.py') + + +@pytest.fixture(autouse=True) +def _skip_integration(request): + running_integration_tests = request.config.getoption("--integration") + is_integration_test = request.node.get_closest_marker("integration") + if running_integration_tests and not is_integration_test: + pytest.skip("running integration tests only") + if not running_integration_tests and is_integration_test: + pytest.skip("skipping integration tests") -- cgit v1.2.1 From c42cbb1c60c5b5d1798ebe470100ed26fb02506d Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Sat, 13 Nov 2021 09:40:47 +0000 Subject: Disable pytest plugins in integration tests via -p no:* --- conftest.py | 4 ---- 1 file changed, 4 deletions(-) (limited to 'conftest.py') diff --git a/conftest.py b/conftest.py index c4e4fec5..96431a57 100644 --- a/conftest.py +++ b/conftest.py @@ -20,10 +20,6 @@ def pytest_addoption(parser): def pytest_configure(config): config.addinivalue_line("markers", "integration: indicate integration tests") - if config.option.integration: - # Assume unit tests and flake already run - config.option.flake8 = False - collect_ignore = [ 'tests/manual_test.py', -- cgit v1.2.1 From 60dcba4c3b9f40f0dc9180bcf4f9954087ff9aad Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Sat, 13 Nov 2021 10:49:03 +0000 Subject: Fix flake8 errors for conftest.py --- conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'conftest.py') diff --git a/conftest.py b/conftest.py index 96431a57..43f33ba4 100644 --- a/conftest.py +++ b/conftest.py @@ -18,7 +18,7 @@ def pytest_addoption(parser): def pytest_configure(config): - config.addinivalue_line("markers", "integration: indicate integration tests") + config.addinivalue_line("markers", "integration: integration tests") collect_ignore = [ -- cgit v1.2.1 From e91969a6bd63fb526ead83f97830bbc4bff139e3 Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Wed, 9 Feb 2022 17:46:59 +0000 Subject: Add a 'uses_network' marker to tests that require connectivity --- conftest.py | 1 + 1 file changed, 1 insertion(+) (limited to 'conftest.py') diff --git a/conftest.py b/conftest.py index 43f33ba4..723e5b43 100644 --- a/conftest.py +++ b/conftest.py @@ -19,6 +19,7 @@ def pytest_addoption(parser): def pytest_configure(config): config.addinivalue_line("markers", "integration: integration tests") + config.addinivalue_line("markers", "uses_network: tests may try to download files") collect_ignore = [ -- cgit v1.2.1 From 5d4fbb320f4ed67ba875ba3afcfe414a80240dc0 Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Wed, 30 Mar 2022 20:25:31 +0100 Subject: Fix flake8 errors --- conftest.py | 1 + 1 file changed, 1 insertion(+) (limited to 'conftest.py') diff --git a/conftest.py b/conftest.py index 723e5b43..2271ec3e 100644 --- a/conftest.py +++ b/conftest.py @@ -32,6 +32,7 @@ collect_ignore = [ 'pkg_resources/tests/data', 'setuptools/_vendor', 'pkg_resources/_vendor', + 'setuptools/config/_validate_pyproject', ] -- cgit v1.2.1