Skip to content

Commit bb982cb

Browse files
committed
use path objects consistently
1 parent fd64a22 commit bb982cb

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

codeflash/discovery/discover_unit_tests.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -490,13 +490,13 @@ def discover_tests_pytest(
490490

491491
def discover_tests_unittest(
492492
cfg: TestConfig,
493-
discover_only_these_tests: list[str] | None = None,
493+
discover_only_these_tests: list[Path] | None = None,
494494
functions_to_optimize: list[FunctionToOptimize] | None = None,
495495
) -> tuple[dict[str, set[FunctionCalledInTest]], int, int]:
496496
tests_root: Path = cfg.tests_root
497497
loader: unittest.TestLoader = unittest.TestLoader()
498498
tests: unittest.TestSuite = loader.discover(str(tests_root))
499-
file_to_test_map: defaultdict[str, list[TestsInFile]] = defaultdict(list)
499+
file_to_test_map: defaultdict[Path, list[TestsInFile]] = defaultdict(list)
500500

501501
def get_test_details(_test: unittest.TestCase) -> TestsInFile | None:
502502
_test_function, _test_module, _test_suite_name = (
@@ -508,7 +508,7 @@ def get_test_details(_test: unittest.TestCase) -> TestsInFile | None:
508508
_test_module_path = Path(_test_module.replace(".", os.sep)).with_suffix(".py")
509509
_test_module_path = tests_root / _test_module_path
510510
if not _test_module_path.exists() or (
511-
discover_only_these_tests and str(_test_module_path) not in discover_only_these_tests
511+
discover_only_these_tests and _test_module_path not in discover_only_these_tests
512512
):
513513
return None
514514
if "__replay_test" in str(_test_module_path):
@@ -518,7 +518,7 @@ def get_test_details(_test: unittest.TestCase) -> TestsInFile | None:
518518
else:
519519
test_type = TestType.EXISTING_UNIT_TEST
520520
return TestsInFile(
521-
test_file=str(_test_module_path),
521+
test_file=_test_module_path,
522522
test_function=_test_function,
523523
test_type=test_type,
524524
test_class=_test_suite_name,
@@ -539,11 +539,11 @@ def get_test_details(_test: unittest.TestCase) -> TestsInFile | None:
539539
continue
540540
details = get_test_details(test_2)
541541
if details is not None:
542-
file_to_test_map[str(details.test_file)].append(details)
542+
file_to_test_map[details.test_file].append(details)
543543
else:
544544
details = get_test_details(test)
545545
if details is not None:
546-
file_to_test_map[str(details.test_file)].append(details)
546+
file_to_test_map[details.test_file].append(details)
547547
return process_test_files(file_to_test_map, cfg, functions_to_optimize)
548548

549549

0 commit comments

Comments
 (0)