diff --git a/testing/example_scripts/fixtures/custom_item/conftest.py b/testing/example_scripts/fixtures/custom_item/conftest.py new file mode 100644 index 000000000..25299d726 --- /dev/null +++ b/testing/example_scripts/fixtures/custom_item/conftest.py @@ -0,0 +1,10 @@ +import pytest + + +class CustomItem(pytest.Item, pytest.File): + def runtest(self): + pass + + +def pytest_collect_file(path, parent): + return CustomItem(path, parent) diff --git a/testing/example_scripts/fixtures/custom_item/foo/__init__.py b/testing/example_scripts/fixtures/custom_item/foo/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/testing/example_scripts/fixtures/custom_item/foo/test_foo.py b/testing/example_scripts/fixtures/custom_item/foo/test_foo.py new file mode 100644 index 000000000..f17482385 --- /dev/null +++ b/testing/example_scripts/fixtures/custom_item/foo/test_foo.py @@ -0,0 +1,2 @@ +def test(): + pass diff --git a/testing/python/fixture.py b/testing/python/fixture.py index 70d79ab71..240d7a08f 100644 --- a/testing/python/fixture.py +++ b/testing/python/fixture.py @@ -1619,6 +1619,11 @@ class TestFixtureManagerParseFactories(object): reprec = testdir.inline_run() reprec.assertoutcome(passed=2) + def test_collect_custom_items(self, testdir): + testdir.copy_example("fixtures/custom_item") + result = testdir.runpytest("foo") + result.stdout.fnmatch_lines("*passed*") + class TestAutouseDiscovery(object): @pytest.fixture