Skip to content
This repository was archived by the owner on Mar 13, 2024. It is now read-only.

Commit 89f0ce5

Browse files
OCoppingcoretl
authored andcommitted
Added missing 'cwd' in __main__.py for branch checking; Added exception catch to test_existing_module
1 parent 23cf8ad commit 89f0ce5

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

src/dls_python3_skeleton/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def replace_text(text: str) -> str:
6666
text = text.replace("[email protected]", email)
6767
return text
6868

69-
branches = [x[2:] for x in str(git("branch", "--list")).split("\n")]
69+
branches = [x[2:] for x in str(git("branch", "--list", cwd=path)).split("\n")]
7070

7171
if MERGE_BRANCH in branches:
7272
raise Exception(

tests/test_dls_python3_skeleton.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -95,26 +95,28 @@ def test_existing_module(tmp_path: Path):
9595
Instructions on how to develop this module are in CONTRIBUTING.rst
9696
"""
9797
)
98-
98+
__main__.git("merge", "--abort", cwd=str(module))
9999
MERGE_BRANCH = "skeleton-merge-branch"
100-
output = check_output(
101-
sys.executable,
102-
"-m",
103-
"dls_python3_skeleton",
104-
"existing",
105-
str(module),
106-
)
107-
assert output.endswith(
100+
101+
with pytest.raises(Exception) as excinfo:
102+
output = check_output(
103+
sys.executable,
104+
"-m",
105+
"dls_python3_skeleton",
106+
"existing",
107+
str(module),
108+
)
109+
assert (
108110
f"{MERGE_BRANCH} already exists. \
109111
Please run 'dls-python3-skeleton clean' to remove it."
112+
in str(excinfo.value)
110113
)
111114

112115
branches = [
113116
x[2:]
114117
for x in str(__main__.git("branch", "--list", cwd=str(module))).split("\n")
115118
]
116119
assert MERGE_BRANCH in branches
117-
# __main__.git("checkout", "-", cwd=str(module))
118120
output = check_output(
119121
sys.executable,
120122
"-m",

0 commit comments

Comments
 (0)