@@ -215,57 +215,6 @@ def test_foo():
215
215
assert imported .data == 42
216
216
217
217
218
- def test_inline_run_clean_sys_paths (testdir ):
219
- def test_sys_path_change_cleanup (self , testdir ):
220
- test_path1 = testdir .tmpdir .join ("boink1" ).strpath
221
- test_path2 = testdir .tmpdir .join ("boink2" ).strpath
222
- test_path3 = testdir .tmpdir .join ("boink3" ).strpath
223
- sys .path .append (test_path1 )
224
- sys .meta_path .append (test_path1 )
225
- original_path = list (sys .path )
226
- original_meta_path = list (sys .meta_path )
227
- test_mod = testdir .makepyfile (
228
- """
229
- import sys
230
- sys.path.append({:test_path2})
231
- sys.meta_path.append({:test_path2})
232
- def test_foo():
233
- sys.path.append({:test_path3})
234
- sys.meta_path.append({:test_path3})""" .format (
235
- locals ()
236
- )
237
- )
238
- testdir .inline_run (str (test_mod ))
239
- assert sys .path == original_path
240
- assert sys .meta_path == original_meta_path
241
-
242
- def spy_factory (self ):
243
- class SysPathsSnapshotSpy (object ):
244
- instances = []
245
-
246
- def __init__ (self ):
247
- SysPathsSnapshotSpy .instances .append (self )
248
- self ._spy_restore_count = 0
249
- self .__snapshot = SysPathsSnapshot ()
250
-
251
- def restore (self ):
252
- self ._spy_restore_count += 1
253
- return self .__snapshot .restore ()
254
-
255
- return SysPathsSnapshotSpy
256
-
257
- def test_inline_run_taking_and_restoring_a_sys_paths_snapshot (
258
- self , testdir , monkeypatch
259
- ):
260
- spy_factory = self .spy_factory ()
261
- monkeypatch .setattr (pytester , "SysPathsSnapshot" , spy_factory )
262
- test_mod = testdir .makepyfile ("def test_foo(): pass" )
263
- testdir .inline_run (str (test_mod ))
264
- assert len (spy_factory .instances ) == 1
265
- spy = spy_factory .instances [0 ]
266
- assert spy ._spy_restore_count == 1
267
-
268
-
269
218
def test_assert_outcomes_after_pytest_error (testdir ):
270
219
testdir .makepyfile ("def test_foo(): assert True" )
271
220
0 commit comments