@@ -400,16 +400,34 @@ def pytest_runtest_makereport(self, item, call):
400400
401401 stats_collector = StatsCollector ()
402402
403+ pytest_args = ['-x' , '-q' ]
404+ if tests :
405+ pytest_args += list (tests )
406+ else :
407+ tests_dir = mutmut .config .tests_dir
408+ if tests_dir :
409+ pytest_args += tests_dir
403410 with change_cwd ('mutants' ):
404- return int (self .execute_pytest ([ '-x' , '-q' ] + list ( tests ) , plugins = [stats_collector ]))
411+ return int (self .execute_pytest (pytest_args , plugins = [stats_collector ]))
405412
406413 def run_tests (self , * , mutant_name , tests ):
414+ pytest_args = ['-x' , '-q' ]
415+ if tests :
416+ pytest_args += list (tests )
417+ else :
418+ tests_dir = mutmut .config .tests_dir
419+ if tests_dir :
420+ pytest_args += tests_dir
407421 with change_cwd ('mutants' ):
408- return int (self .execute_pytest ([ '-x' , '-q' ] + list ( tests ) ))
422+ return int (self .execute_pytest (pytest_args ))
409423
410424 def run_forced_fail (self ):
425+ pytest_args = ['-x' , '-q' ]
426+ tests_dir = mutmut .config .tests_dir
427+ if tests_dir :
428+ pytest_args += tests_dir
411429 with change_cwd ('mutants' ):
412- return int (self .execute_pytest ([ '-x' , '-q' ] ))
430+ return int (self .execute_pytest (pytest_args ))
413431
414432 def list_all_tests (self ):
415433 class TestsCollector :
@@ -418,8 +436,13 @@ def pytest_collection_modifyitems(self, items):
418436
419437 collector = TestsCollector ()
420438
439+ tests_dir = mutmut .config .tests_dir
440+ pytest_args = ['-x' , '-q' , '--collect-only' ]
441+ if tests_dir :
442+ pytest_args += tests_dir
443+
421444 with change_cwd ('mutants' ):
422- exit_code = int (self .execute_pytest ([ '-x' , '-q' , '--collect-only' ] , plugins = [collector ]))
445+ exit_code = int (self .execute_pytest (pytest_args , plugins = [collector ]))
423446 if exit_code != 0 :
424447 raise CollectTestsFailedException ()
425448
@@ -623,6 +646,7 @@ class Config:
623646 max_stack_depth : int
624647 debug : bool
625648 paths_to_mutate : List [Path ]
649+ tests_dir : List [str ] = None
626650
627651 def should_ignore_for_mutation (self , path ):
628652 if not str (path ).endswith ('.py' ):
@@ -701,7 +725,8 @@ def load_config():
701725 paths_to_mutate = [
702726 Path (y )
703727 for y in s ('paths_to_mutate' , [])
704- ] or guess_paths_to_mutate ()
728+ ] or guess_paths_to_mutate (),
729+ tests_dir = s ('tests_dir' , []),
705730 )
706731
707732
0 commit comments