MCPcopy Create free account
hub / github.com/pytest-dev/pytest / test_getcustomfile_roundtrip

Method test_getcustomfile_roundtrip

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

Source from the content-addressed store, hash-verified

94 assert fn.function is not None
95
96 def test_getcustomfile_roundtrip(self, pytester: Pytester) -> None:
97 hello = pytester.makefile(".xxx", hello="world")
98 pytester.makepyfile(
99 conftest="""
100 import pytest
101 class CustomFile(pytest.File):
102 pass
103 def pytest_collect_file(file_path, parent):
104 if file_path.suffix == ".xxx":
105 return CustomFile.from_parent(path=file_path, parent=parent)
106 """
107 )
108 node = pytester.getpathnode(hello)
109 assert isinstance(node, pytest.File)
110 assert node.name == "hello.xxx"
111 nodes = node.session.perform_collect([node.nodeid], genitems=False)
112 assert len(nodes) == 1
113 assert isinstance(nodes[0], pytest.File)
114
115 def test_can_skip_class_with_test_attr(self, pytester: Pytester) -> None:
116 """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