From 8c6aa57034342f8c2dfedfc72a17146906e07853 Mon Sep 17 00:00:00 2001 From: mhucka Date: Thu, 16 Jul 2026 19:51:23 +0000 Subject: [PATCH 1/3] Add pytest flag `--skipslow` to `conftest.py` --- conftest.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/conftest.py b/conftest.py index 080bcba9d..78cfd57fb 100644 --- a/conftest.py +++ b/conftest.py @@ -66,3 +66,12 @@ def set_threadpool_limits(): yield else: yield + + +def pytest_addoption(parser: Any) -> None: + parser.addoption("--skipslow", action="store_true", help="skips slow tests") + + +def pytest_runtest_setup(item: Any) -> None: + if "slow" in item.keywords and item.config.getvalue("skipslow"): + pytest.skip("skipped because of --skipslow option") From 44f76c03d1580b3365786c44184015c9d41664eb Mon Sep 17 00:00:00 2001 From: mhucka Date: Thu, 16 Jul 2026 19:51:39 +0000 Subject: [PATCH 2/3] Use new `--skipslow` flag --- .github/workflows/ci.yaml | 6 +++--- CONTRIBUTING.md | 2 +- pyproject.toml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 9c218399f..e642299f1 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -130,7 +130,7 @@ jobs: - name: Run pytest run: | echo '::add-matcher::.github/problem-matchers/pytest.json' - check/pytest -n auto -m "not slow" + check/pytest -n auto --skipslow pytest-extra: name: Extra unit tests @@ -162,7 +162,7 @@ jobs: - name: Run pytest run: | echo '::add-matcher::.github/problem-matchers/pytest.json' - check/pytest -n auto -m "not slow" src/openfermion/resource_estimates + check/pytest -n auto --skipslow src/openfermion/resource_estimates pytest-compat: name: Python compatibility tests @@ -190,7 +190,7 @@ jobs: - name: Run pytest run: | echo '::add-matcher::.github/problem-matchers/pytest.json' - check/pytest -n auto -m "not slow" + check/pytest -n auto --skipslow coverage: name: Python code coverage tests diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e4b603e49..3db515805 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -293,7 +293,7 @@ We use [pytest](https://docs.pytest.org) to run our tests and in the `check/` subdirectory to run these programs. * During development, periodically check that code changes do not break anything. For fast checks, - run `check/pytest -m "not slow" -n auto PATH ...`, where `PATH ...` is one or more directories + run `check/pytest --skipslow -n auto PATH ...`, where `PATH ...` is one or more directories or `_test.py` files to test. (The `-n auto` option makes pytest use parallel processes; omit it if it causes problems on your system.) diff --git a/pyproject.toml b/pyproject.toml index 72ba61d15..b8aa9b48a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,7 +25,7 @@ disable_warnings = ["no-sysmon"] [tool.pytest.ini_options] markers = [ - """slow: marks tests as slow (deselect with '-m "not slow"')""", + """slow: marks tests as slow (skip with '--skipslow')""", ] filterwarnings = [ "ignore:Skipped assert_qasm_is_consistent_with_unitary because qiskit.*:UserWarning", From 0468d66982f99c1243b09fc69c1489c87eba17c1 Mon Sep 17 00:00:00 2001 From: Michael Hucka Date: Thu, 16 Jul 2026 13:00:03 -0700 Subject: [PATCH 3/3] Update conftest.py Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- conftest.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/conftest.py b/conftest.py index 78cfd57fb..3e50ce02f 100644 --- a/conftest.py +++ b/conftest.py @@ -68,10 +68,10 @@ def set_threadpool_limits(): yield -def pytest_addoption(parser: Any) -> None: +def pytest_addoption(parser: pytest.Parser) -> None: parser.addoption("--skipslow", action="store_true", help="skips slow tests") -def pytest_runtest_setup(item: Any) -> None: - if "slow" in item.keywords and item.config.getvalue("skipslow"): +def pytest_runtest_setup(item: pytest.Item) -> None: + if "slow" in item.keywords and item.config.getoption("skipslow"): pytest.skip("skipped because of --skipslow option")