From 26431e9e46788afead24e1ef3ab22345653f65d3 Mon Sep 17 00:00:00 2001 From: Kevin Sheppard Date: Tue, 12 Nov 2024 08:55:33 +0000 Subject: [PATCH] BUG: Remove pytest import from top of module Move import to within the test function and change skip method --- patsy/eval.py | 16 ++++++++-------- tox.ini | 1 + 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/patsy/eval.py b/patsy/eval.py index 0919787..f63c4d3 100644 --- a/patsy/eval.py +++ b/patsy/eval.py @@ -18,7 +18,6 @@ import tokenize import ast import numbers -import pytest from patsy import PatsyError from patsy.util import PushbackAdapter, no_pickling, assert_no_pickling from patsy.tokens import pretty_untokenize, normalize_token_spacing, python_tokenize @@ -424,14 +423,15 @@ def test_EvalEnvironment_subset(): pytest.raises(NameError, subset_bc.eval, "a") -@pytest.mark.skipif( - sys.version_info >= (3, 13), - reason=( - "`frame.f_locals` may return write-through proxies in Python 3.13+, " - "breaking direct comparison by ids." - ), -) def test_EvalEnvironment_eq(): + import pytest + + if sys.version_info >= (3, 13): + pytest.skip( + "`frame.f_locals` may return write-through proxies in Python 3.13+, " + "breaking direct comparison by ids." + ) + # Two environments are eq only if they refer to exactly the same # global/local dicts env1 = EvalEnvironment.capture(0) diff --git a/tox.ini b/tox.ini index 58677a1..3c76f4f 100644 --- a/tox.ini +++ b/tox.ini @@ -29,6 +29,7 @@ setenv= allowlist_externals= env commands= + python -c "import patsy" pytest -vv --cov=patsy --cov-config={toxinidir}/.coveragerc --cov-report=term-missing --cov-report=xml --cov-report=html:{toxworkdir}/coverage/{envname} {posargs:} env PATSY_AVOID_OPTIONAL_DEPENDENCIES=1 pytest -vv --cov=patsy --cov-config={toxinidir}/.coveragerc --cov-report=term-missing --cov-report=xml --cov-report=html:{toxworkdir}/coverage/{envname} {posargs:} python {toxinidir}/tools/check-API-refs.py