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

Method setuptestfs

testing/test_pathlib.py:144–191  ·  view source on GitHub ↗
(self, path: Path)

Source from the content-addressed store, hash-verified

142 yield
143
144 def setuptestfs(self, path: Path) -> None:
145 # print "setting up test fs for", repr(path)
146 samplefile = path / "samplefile"
147 samplefile.write_text("samplefile\n", encoding="utf-8")
148
149 execfile = path / "execfile"
150 execfile.write_text("x=42", encoding="utf-8")
151
152 execfilepy = path / "execfile.py"
153 execfilepy.write_text("x=42", encoding="utf-8")
154
155 d = {1: 2, "hello": "world", "answer": 42}
156 path.joinpath("samplepickle").write_bytes(pickle.dumps(d, 1))
157
158 sampledir = path / "sampledir"
159 sampledir.mkdir()
160 sampledir.joinpath("otherfile").touch()
161
162 otherdir = path / "otherdir"
163 otherdir.mkdir()
164 otherdir.joinpath("__init__.py").touch()
165
166 module_a = otherdir / "a.py"
167 module_a.write_text("from .b import stuff as result\n", encoding="utf-8")
168 module_b = otherdir / "b.py"
169 module_b.write_text('stuff="got it"\n', encoding="utf-8")
170 module_c = otherdir / "c.py"
171 module_c.write_text(
172 dedent(
173 """
174 import pluggy;
175 import otherdir.a
176 value = otherdir.a.result
177 """
178 ),
179 encoding="utf-8",
180 )
181 module_d = otherdir / "d.py"
182 module_d.write_text(
183 dedent(
184 """
185 import pluggy;
186 from otherdir import a
187 value2 = a.result
188 """
189 ),
190 encoding="utf-8",
191 )
192
193 def test_smoke_test(self, path1: Path, ns_param: bool) -> None:
194 obj = import_path(

Callers 1

path1Method · 0.95

Calls 3

write_textMethod · 0.80
dumpsMethod · 0.80
mkdirMethod · 0.45

Tested by

no test coverage detected