diff --git a/testing/python/collect.py b/testing/python/collect.py index 1a85faf9c..0dd9ef1da 100644 --- a/testing/python/collect.py +++ b/testing/python/collect.py @@ -1076,3 +1076,19 @@ def test_dont_collect_non_function_callable(testdir): 'WC2 *', '*1 passed, 1 pytest-warnings in *', ]) + + +def test_class_injection_does_not_break_collection(testdir): + testdir.makeconftest(""" + from test_inject import TestClass + def pytest_generate_tests(metafunc): + TestClass.changed_var = {} + """) + testdir.makepyfile(test_inject=''' + class TestClass(object): + def test_injection(self): + """Test being parametrized.""" + pass + ''') + result = testdir.runpytest() + assert "RuntimeError: dictionary changed size during iteration" not in result.stdout.str() \ No newline at end of file