File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -413,6 +413,29 @@ def microvm(test_fc_session_root_path, bin_cloner_path):
413
413
shutil .rmtree (os .path .join (test_fc_session_root_path , vm .id ))
414
414
415
415
416
+ @pytest .fixture ()
417
+ def microvm_factory (tmp_path , bin_cloner_path ):
418
+ """Fixture to create microvms simply.
419
+
420
+ By using tmp_path, the last 3 runs are kept. This may be a problem when
421
+ running large number of tests, but it's very handy for debugging.
422
+ """
423
+
424
+ class MicroVMFactory :
425
+ """MicroVM factory"""
426
+
427
+ def __init__ (self , tmp_path , bin_cloner ):
428
+ self .tmp_path = tmp_path
429
+ self .bin_cloner_path = bin_cloner
430
+
431
+ def build (self ):
432
+ """Build a fresh microvm."""
433
+ vm = init_microvm (self .tmp_path , self .bin_cloner_path )
434
+ return vm
435
+
436
+ yield MicroVMFactory (tmp_path , bin_cloner_path )
437
+
438
+
416
439
@pytest .fixture
417
440
def network_config ():
418
441
"""Yield a UniqueIPv4Generator."""
You can’t perform that action at this time.
0 commit comments