Skip to content

Commit 850162f

Browse files
fixup: enhance tests for hg command override to work on windows
1 parent 75869c1 commit 850162f

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

testing/test_mercurial.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,14 @@ def test_hg_command_from_env(
7373
request: pytest.FixtureRequest,
7474
hg_exe: str,
7575
) -> None:
76-
with monkeypatch.context() as m:
77-
m.setenv("SETUPTOOLS_SCM_HG_COMMAND", hg_exe)
78-
m.setenv("PATH", str(wd.cwd / "not-existing"))
79-
wd.write("pyproject.toml", "[tool.setuptools_scm]")
80-
# Use the configured hg command for test operations
81-
wd.add_command = f"{hg_exe} add ."
82-
wd.commit_command = f'{hg_exe} commit -m test-{{reason}} -u test -d "0 0"'
83-
# Need to commit something first for versioning to work
84-
wd.commit_testfile()
85-
version = wd.get_version()
86-
assert version.startswith("0.1.dev1+")
76+
wd.write("pyproject.toml", "[tool.setuptools_scm]")
77+
# Need to commit something first for versioning to work
78+
wd.commit_testfile()
79+
80+
monkeypatch.setenv("SETUPTOOLS_SCM_HG_COMMAND", hg_exe)
81+
monkeypatch.setenv("PATH", str(wd.cwd / "not-existing"))
82+
version = wd.get_version()
83+
assert version.startswith("0.1.dev1+")
8784

8885

8986
def test_hg_command_from_env_is_invalid(
@@ -94,7 +91,7 @@ def test_hg_command_from_env_is_invalid(
9491
# No module reloading needed - runtime configuration works immediately
9592
config = Configuration()
9693
wd.write("pyproject.toml", "[tool.setuptools_scm]")
97-
with pytest.raises(CommandNotFoundError, match=r"hg"):
94+
with pytest.raises(CommandNotFoundError, match=r"test.*hg.*not-existing"):
9895
parse(wd.cwd, config=config)
9996

10097
assert wd.get_version(fallback_version="1.0") == "1.0"

0 commit comments

Comments
 (0)