Skip to content

Commit 474827e

Browse files
committed
Add failing test
1 parent 7cad371 commit 474827e

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

‎tests/unit/application/test_usecases.py‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,51 @@ class FakePackageFinder(BaseFakePackageFinder):
6666
with pytest.raises(ValueError, match="Cannot find children of a squashed module."):
6767
graph.find_children(module)
6868

69+
@pytest.mark.xfail(reason="Not yet supported")
70+
def test_namespace_package_passed_as_root(self):
71+
file_system = FakeFileSystem(
72+
contents="""
73+
/path/to/mypackage/
74+
foo/
75+
__init__.py
76+
one.py
77+
two/
78+
__init__.py
79+
green.py
80+
blue.py
81+
bar/
82+
__init__.py
83+
three.py
84+
/different-path/to/mypackage/
85+
foobar/
86+
__init__.py
87+
four.py
88+
""",
89+
)
90+
91+
class FakePackageFinder(BaseFakePackageFinder):
92+
directory_map = {
93+
# TODO - PackageFinder assumes only a single directory per package.
94+
# This isn't the case for namespace packages.
95+
"mypackage": "/path/to/mypackage"
96+
}
97+
98+
with override_settings(FILE_SYSTEM=file_system, PACKAGE_FINDER=FakePackageFinder()):
99+
graph = usecases.build_graph("mypackage")
100+
101+
assert graph.modules == {
102+
"mypackage",
103+
"mypackage.foo",
104+
"mypackage.foo.one",
105+
"mypackage.foo.two",
106+
"mypackage.foo.two.green",
107+
"mypackage.foo.two.blue",
108+
"mypackage.bar",
109+
"mypackage.bar.three",
110+
"mypackage.foobar",
111+
"mypackage.foobar.four",
112+
}
113+
69114
def test_boolean_additional_package_raises_type_error(self):
70115
"""
71116
Tests that a useful error message if build_graph is called

0 commit comments

Comments
 (0)