From dde693ffd68040fcb46880247e715d9dc9496368 Mon Sep 17 00:00:00 2001 From: G Roques Date: Thu, 6 Aug 2020 19:18:38 -0500 Subject: [PATCH] Add tests with the same path over different sys.path cases --- src/tests/parser_test.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/tests/parser_test.py b/src/tests/parser_test.py index ced3b653..05a329ec 100644 --- a/src/tests/parser_test.py +++ b/src/tests/parser_test.py @@ -616,6 +616,24 @@ def test_module_publicity_with_private_paths(private_path): assert not module.is_public +@pytest.mark.parametrize("syspath,is_public", ( + ("/", False), + ("_foo/", True), +)) +def test_module_publicity_with_different_sys_path(syspath, + is_public, + monkeypatch): + """Test module publicity for same path and different sys.path.""" + parser = Parser() + code = CodeSnippet("") + + monkeypatch.syspath_prepend(syspath) + + path = Path("_foo") / "bar" / "baz.py" + module = parser.parse(code, str(path)) + assert module.is_public == is_public + + def test_complex_module(): """Test that a complex module is parsed correctly.""" parser = Parser()