Skip to content

Commit 0bdd5b3

Browse files
committed
TST: Add test for submodule detection outside of repo.
1 parent ecbff1d commit 0bdd5b3

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

tests/test_submodule.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
"""Test submodule detection code."""
2+
3+
import os.path
4+
5+
from check_python_h_first.get_submodule_paths import get_submodule_paths
6+
7+
ROOT_DIR = os.path.dirname(os.path.dirname(__file__))
8+
9+
10+
def test_submodule_paths_gh_pages():
11+
"""Test that we can pick up the gh-pages submodule."""
12+
results = get_submodule_paths()
13+
assert set(results) == {os.path.join(ROOT_DIR, "docs", "_build", "html")}
14+
15+
16+
def test_submodule_paths_no_repo():
17+
"""Test that we pick up no submodules outside a repo.
18+
19+
Will fail if this repository is itself a submodule.
20+
"""
21+
try:
22+
_orig_dir = os.getcwd()
23+
os.chdir(os.path.dirname(ROOT_DIR))
24+
results = get_submodule_paths()
25+
assert results == []
26+
finally:
27+
os.chdir(_orig_dir)

0 commit comments

Comments
 (0)