MCPcopy
hub / github.com/pytest-dev/pytest / test_getcustomfile_roundtrip

Method test_getcustomfile_roundtrip

testing/test_collection.py:103–121  ·  view source on GitHub ↗
(self, pytester: Pytester)

Source from the content-addressed store, hash-verified

101 assert fn.function is not None
102
103 def test_getcustomfile_roundtrip(self, pytester: Pytester) -> None:
104 hello = pytester.makefile(".xxx", hello="world")
105 pytester.makepyfile(
106 conftest="""
107 import pytest
108 class CustomFile(pytest.File):
109 def collect(self):
110 return []
111 def pytest_collect_file(file_path, parent):
112 if file_path.suffix == ".xxx":
113 return CustomFile.from_parent(path=file_path, parent=parent)
114 """
115 )
116 node = pytester.getpathnode(hello)
117 assert isinstance(node, pytest.File)
118 assert node.name == "hello.xxx"
119 nodes = node.session.perform_collect([node.nodeid], genitems=False)
120 assert len(nodes) == 1
121 assert isinstance(nodes[0], pytest.File)
122
123 def test_can_skip_class_with_test_attr(self, pytester: Pytester) -> None:
124 """Assure test class is skipped when using `__test__=False` (See #2007)."""

Callers

nothing calls this directly

Calls 4

perform_collectMethod · 0.80
makefileMethod · 0.45
makepyfileMethod · 0.45
getpathnodeMethod · 0.45

Tested by

no test coverage detected