Skip to content
Prev Previous commit
Next Next commit
Improve docs
  • Loading branch information
nicoddemus committed Apr 2, 2021
commit eeb588995ae325f2690481da09e43a3f661e7a44
4 changes: 2 additions & 2 deletions src/_pytest/pathlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,8 +476,8 @@ def import_path(
at all. It effectively allows having same-named test modules in different places.

:param root:
Is used when mode == ImportMode.importlib, and is used as an anchor to obtain
a unique module name for the module being imported, so it can safely be stashed
Used as an anchor when mode == ImportMode.importlib to obtain
a unique name for the module being imported so it can safely be stored
into ``sys.modules``.

:raises ImportPathMismatchError:
Expand Down
1 change: 1 addition & 0 deletions testing/test_pathlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,5 +552,6 @@ def test_module_name_from_path(tmp_path: Path) -> None:
result = module_name_from_path(tmp_path / "src/tests/test_foo.py", tmp_path)
assert result == "src.tests.test_foo"

# Path is not relative to root dir: use the full path to obtain the module name.
result = module_name_from_path(Path("/home/foo/test_foo.py"), Path("/bar"))
assert result == "home.foo.test_foo"