|
1 | 1 | import pytest
|
2 | 2 |
|
3 |
| -from docstub._path_utils import walk_source_package |
| 3 | +from docstub._path_utils import STUB_HEADER_COMMENT, walk_source_package |
4 | 4 |
|
5 | 5 |
|
6 | 6 | class Test_walk_source_package:
|
@@ -47,6 +47,26 @@ def test_not_a_package(self, tmp_path):
|
47 | 47 | with pytest.raises(TypeError, match=".* must be a Python file or package"):
|
48 | 48 | next(walk_source_package(tmp_path))
|
49 | 49 |
|
| 50 | + def test_single_with_docstub_generated_stub(self, tmp_path): |
| 51 | + script_py = tmp_path / "script.py" |
| 52 | + script_py.touch() |
| 53 | + script_stub = tmp_path / "script.pyi" |
| 54 | + with script_stub.open("w") as io: |
| 55 | + io.write(STUB_HEADER_COMMENT) |
| 56 | + |
| 57 | + paths = sorted(walk_source_package(script_py)) |
| 58 | + assert paths == [script_py] |
| 59 | + |
| 60 | + def test_package_with_docstub_generated_stub(self, tmp_path): |
| 61 | + init_py = tmp_path / "__init__.py" |
| 62 | + init_py.touch() |
| 63 | + init_stub = tmp_path / "__init__.pyi" |
| 64 | + with init_stub.open("w") as io: |
| 65 | + io.write(STUB_HEADER_COMMENT) |
| 66 | + |
| 67 | + paths = sorted(walk_source_package(tmp_path)) |
| 68 | + assert paths == [init_py] |
| 69 | + |
50 | 70 | @pytest.mark.parametrize("name", ["script.py", "script.pyi"])
|
51 | 71 | def test_ignore_single_file(self, tmp_path, name):
|
52 | 72 | top_stub = tmp_path / name
|
|
0 commit comments