Skip to content

Commit fe7e793

Browse files
committed
Add test for collecting task modules with the same name.
1 parent 0c104d2 commit fe7e793

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

tests/test_collect.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,24 @@ def task_write_text(depends_on, produces):
3838

3939

4040
@pytest.mark.end_to_end()
41-
def test_collect_module_name_(tmp_path):
41+
def test_collect_tasks_from_modules_with_the_same_name(tmp_path):
42+
"""We need to check that task modules can have the same name. See #373 and #374."""
43+
tmp_path.joinpath("a").mkdir()
44+
tmp_path.joinpath("b").mkdir()
45+
tmp_path.joinpath("a", "task_module.py").write_text("def task_a(): pass")
46+
tmp_path.joinpath("b", "task_module.py").write_text("def task_a(): pass")
47+
session = main({"paths": tmp_path})
48+
assert len(session.collection_reports) == 2
49+
assert all(
50+
report.outcome == CollectionOutcome.SUCCESS
51+
for report in session.collection_reports
52+
)
53+
assert session.collection_reports[0].node.function.__module__ == "a.task_module"
54+
assert session.collection_reports[1].node.function.__module__ == "b.task_module"
55+
56+
57+
@pytest.mark.end_to_end()
58+
def test_collect_module_name(tmp_path):
4259
"""We need to add a task module to the sys.modules. See #373 and #374."""
4360
source = """
4461
# without this import, everything works fine

0 commit comments

Comments
 (0)