summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnderson Bravalheri <andersonbravalheri@gmail.com>2021-11-08 13:01:27 +0000
committerAnderson Bravalheri <andersonbravalheri@gmail.com>2021-12-21 02:22:10 +0000
commite645104656fda22f4c0c2b3d9841ed792b1e7103 (patch)
tree62f183062a42d4c306d4e25e97d3fe975083192e
parent9288c6f3f039bf51f997a99ae8766ed02ed92cda (diff)
downloadpython-setuptools-git-e645104656fda22f4c0c2b3d9841ed792b1e7103.tar.gz
Configure pytest to enable/disable integration tests
-rw-r--r--conftest.py24
1 files changed, 24 insertions, 0 deletions
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")