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

Method setuptestfs

testing/test_pathlib.py:144–191  ·  testing/test_pathlib.py::TestImportPath.setuptestfs
(self, path: Path)

Source from the content-addressed store, hash-verified

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