@@ -397,16 +397,34 @@ def pytest_runtest_makereport(self, item, call):
397397
398398 stats_collector = StatsCollector ()
399399
400+ pytest_args = ['-x' , '-q' ]
401+ if tests :
402+ pytest_args += list (tests )
403+ else :
404+ tests_dir = getattr (mutmut .config , 'tests_dir' , None )
405+ if tests_dir :
406+ pytest_args .append (tests_dir )
400407 with change_cwd ('mutants' ):
401- return int (self .execute_pytest ([ '-x' , '-q' ] + list ( tests ) , plugins = [stats_collector ]))
408+ return int (self .execute_pytest (pytest_args , plugins = [stats_collector ]))
402409
403410 def run_tests (self , * , mutant_name , tests ):
411+ pytest_args = ['-x' , '-q' ]
412+ if tests :
413+ pytest_args += list (tests )
414+ else :
415+ tests_dir = getattr (mutmut .config , 'tests_dir' , None )
416+ if tests_dir :
417+ pytest_args .append (tests_dir )
404418 with change_cwd ('mutants' ):
405- return int (self .execute_pytest ([ '-x' , '-q' ] + list ( tests ) ))
419+ return int (self .execute_pytest (pytest_args ))
406420
407421 def run_forced_fail (self ):
422+ pytest_args = ['-x' , '-q' ]
423+ tests_dir = getattr (mutmut .config , 'tests_dir' , None )
424+ if tests_dir :
425+ pytest_args .append (tests_dir )
408426 with change_cwd ('mutants' ):
409- return int (self .execute_pytest ([ '-x' , '-q' ] ))
427+ return int (self .execute_pytest (pytest_args ))
410428
411429 def list_all_tests (self ):
412430 class TestsCollector :
@@ -415,8 +433,13 @@ def pytest_collection_modifyitems(self, items):
415433
416434 collector = TestsCollector ()
417435
436+ tests_dir = getattr (mutmut .config , 'tests_dir' , None )
437+ pytest_args = ['-x' , '-q' , '--collect-only' ]
438+ if tests_dir :
439+ pytest_args .append (tests_dir )
440+
418441 with change_cwd ('mutants' ):
419- exit_code = int (self .execute_pytest ([ '-x' , '-q' , '--collect-only' ] , plugins = [collector ]))
442+ exit_code = int (self .execute_pytest (pytest_args , plugins = [collector ]))
420443 if exit_code != 0 :
421444 raise CollectTestsFailedException ()
422445
@@ -620,6 +643,7 @@ class Config:
620643 max_stack_depth : int
621644 debug : bool
622645 paths_to_mutate : List [Path ]
646+ tests_dir : str = None
623647
624648 def should_ignore_for_mutation (self , path ):
625649 if not str (path ).endswith ('.py' ):
@@ -698,7 +722,8 @@ def load_config():
698722 paths_to_mutate = [
699723 Path (y )
700724 for y in s ('paths_to_mutate' , [])
701- ] or guess_paths_to_mutate ()
725+ ] or guess_paths_to_mutate (),
726+ tests_dir = s ('tests_dir' , None ),
702727 )
703728
704729
0 commit comments