@@ -272,52 +272,69 @@ def virtualenv_template(request, tmpdir_factory, pip_src,
272
272
yield venv
273
273
274
274
275
+ @pytest .fixture (scope = "session" )
276
+ def virtualenv_factory (virtualenv_template ):
277
+ def factory (tmpdir ):
278
+ return VirtualEnvironment (tmpdir , virtualenv_template )
279
+
280
+ return factory
281
+
282
+
275
283
@pytest .fixture
276
- def virtualenv (virtualenv_template , tmpdir , isolate ):
284
+ def virtualenv (virtualenv_factory , tmpdir ):
277
285
"""
278
286
Return a virtual environment which is unique to each test function
279
287
invocation created inside of a sub directory of the test function's
280
288
temporary directory. The returned object is a
281
289
``tests.lib.venv.VirtualEnvironment`` object.
282
290
"""
283
- venv_location = tmpdir .joinpath ("workspace" , "venv" )
284
- yield VirtualEnvironment (venv_location , virtualenv_template )
291
+ yield virtualenv_factory (tmpdir .joinpath ("workspace" , "venv" ))
285
292
286
293
287
294
@pytest .fixture
288
295
def with_wheel (virtualenv , wheel_install ):
289
296
install_egg_link (virtualenv , 'wheel' , wheel_install )
290
297
291
298
299
+ @pytest .fixture (scope = "session" )
300
+ def script_factory (virtualenv_factory , deprecated_python ):
301
+ def factory (tmpdir , virtualenv = None ):
302
+ if virtualenv is None :
303
+ virtualenv = virtualenv_factory (tmpdir .joinpath ("venv" ))
304
+ return PipTestEnvironment (
305
+ # The base location for our test environment
306
+ tmpdir ,
307
+
308
+ # Tell the Test Environment where our virtualenv is located
309
+ virtualenv = virtualenv ,
310
+
311
+ # Do not ignore hidden files, they need to be checked as well
312
+ ignore_hidden = False ,
313
+
314
+ # We are starting with an already empty directory
315
+ start_clear = False ,
316
+
317
+ # We want to ensure no temporary files are left behind, so the
318
+ # PipTestEnvironment needs to capture and assert against temp
319
+ capture_temp = True ,
320
+ assert_no_temp = True ,
321
+
322
+ # Deprecated python versions produce an extra deprecation warning
323
+ pip_expect_warning = deprecated_python ,
324
+ )
325
+
326
+ return factory
327
+
328
+
292
329
@pytest .fixture
293
- def script (tmpdir , virtualenv , deprecated_python ):
330
+ def script (tmpdir , virtualenv , script_factory ):
294
331
"""
295
332
Return a PipTestEnvironment which is unique to each test function and
296
333
will execute all commands inside of the unique virtual environment for this
297
334
test function. The returned object is a
298
335
``tests.lib.scripttest.PipTestEnvironment``.
299
336
"""
300
- return PipTestEnvironment (
301
- # The base location for our test environment
302
- tmpdir .joinpath ("workspace" ),
303
-
304
- # Tell the Test Environment where our virtualenv is located
305
- virtualenv = virtualenv ,
306
-
307
- # Do not ignore hidden files, they need to be checked as well
308
- ignore_hidden = False ,
309
-
310
- # We are starting with an already empty directory
311
- start_clear = False ,
312
-
313
- # We want to ensure no temporary files are left behind, so the
314
- # PipTestEnvironment needs to capture and assert against temp
315
- capture_temp = True ,
316
- assert_no_temp = True ,
317
-
318
- # Deprecated python versions produce an extra deprecation warning
319
- pip_expect_warning = deprecated_python ,
320
- )
337
+ return script_factory (tmpdir .joinpath ("workspace" ), virtualenv )
321
338
322
339
323
340
@pytest .fixture (scope = "session" )
@@ -326,6 +343,11 @@ def common_wheels():
326
343
return DATA_DIR .joinpath ('common_wheels' )
327
344
328
345
346
+ @pytest .fixture (scope = "session" )
347
+ def shared_data (tmpdir_factory ):
348
+ return TestData .copy (Path (str (tmpdir_factory .mktemp ("data" ))))
349
+
350
+
329
351
@pytest .fixture
330
352
def data (tmpdir ):
331
353
return TestData .copy (tmpdir .joinpath ("data" ))
@@ -359,7 +381,7 @@ def in_memory_pip():
359
381
return InMemoryPip ()
360
382
361
383
362
- @pytest .fixture
384
+ @pytest .fixture ( scope = "session" )
363
385
def deprecated_python ():
364
386
"""Used to indicate whether pip deprecated this python version"""
365
387
return sys .version_info [:2 ] in [(2 , 7 )]
0 commit comments