Open david-cortes opened 3 months ago
I recall we added a warning for this,
Please materialize the generator, pytest needs to consume them multiple times
Pytest should start to error on non repeatable parametrize marks
I recall we added a warning for this,
Please materialize the generator, pytest needs to consume them multiple times
Pytest should start to error on non repeatable parametrize marks
FWIW, the latest version of pytest
(==8.3.2) doesn't give any warnings here.
Also a addition note parameterization natively does cross products
I'm observing a very odd behavior of tests that are imported from other files getting collected only for one test file when they have parametrized arguments that are generated through
itertools
.Example with 3 files:
common.py
:class CommonTestSuite: @pytest.mark.parametrize( "m,n", itertools.product( [100, 1_000], [100, 1_000], ) ) def test_no_negative_numbers(self, generator, m, n): assert generator(m,n).min() >= 0.
test_gamma.py
:class GammaGenerator: def init(self): self.rng = np.random.default_rng(seed=123) def generate(self, m, n): return self.rng.standard_gamma(1, size=(m,n))
class TestGamma(CommonTestSuite): obj = GammaGenerator()
============================================ test session starts ============================================ platform linux -- Python 3.11.0, pytest-7.4.0, pluggy-1.0.0 rootdir: /home/david/del/pytest_issue plugins: anyio-3.5.0, mypy-0.10.3 collected 5 items