diff --git a/services/path_fixer/tests/unit/test_path_fixer.py b/services/path_fixer/tests/unit/test_path_fixer.py index 34d378dfd..4b3a7b407 100644 --- a/services/path_fixer/tests/unit/test_path_fixer.py +++ b/services/path_fixer/tests/unit/test_path_fixer.py @@ -127,3 +127,25 @@ def test_basepath_uses_own_result_if_main_is_none_multuple_base_paths(self): base_aware_pf("__init__.py", bases_to_try=["/home/travis/build/project"]) == "project/__init__.py" ) + + +def test_ambiguous_paths(): + toc = [ + "foobar/bar/baz.py", + "barfoo/bar/baz.py", + ] + base_path = "/home/runner/work/owner/repo/foobar/build/coverage/coverage.xml" + # ~~~~~~ + bases_to_try = ["/app"] + # The problem here is that the given `file_name` is ambiguous, and neither the + # `base_path` nor the `bases_to_try` is helping us narrow this down. + # The `base_path` does include one of the relevant parent directories, + # but the paths within the coverage file are not relative to *that* file, + # and the `bases_to_try` seem to be completely unrelated. + file_name = "bar/baz.py" + + pf = PathFixer.init_from_user_yaml({}, toc, []) + base_aware_pf = pf.get_relative_path_aware_pathfixer(base_path) + + assert pf(file_name) is None + assert base_aware_pf(file_name, bases_to_try=bases_to_try) is None