Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit32921c3

Browse files
authored
#702 Skip mercurial tests if 'hg' not found (#703)
2 parentsfe83a98 +33a9b1e commit32921c3

File tree

3 files changed

+55
-39
lines changed

3 files changed

+55
-39
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Skip the mercurial tests if not found on the local system.

‎src/towncrier/test/test_hg.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
# See LICENSE for details.
33

44
importos.path
5+
importshutil
6+
importunittest
57

68
frompathlibimportPath
79
fromsubprocessimportcheck_call
@@ -14,6 +16,9 @@
1416
from .helpersimportsetup_simple_project,write
1517

1618

19+
hg_available=shutil.which("hg")isnotNone
20+
21+
1722
defcreate_project(
1823
pyproject_path="pyproject.toml",main_branch="main",extra_config=""
1924
):
@@ -43,6 +48,7 @@ def commit(message):
4348
check_call(["hg","commit","--user","Example <test@example.com>","-m",message])
4449

4550

51+
@unittest.skipUnless(hg_available,"requires 'mercurial' to be installed")
4652
classTestHg(TestCase):
4753
deftest_get_default_compare_branch(self):
4854
"""

‎src/towncrier/test/test_vcs.py‎

Lines changed: 48 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# See LICENSE for details.
33

44
importos.path
5+
importunittest
56

67
frompathlibimportPath
78

@@ -26,57 +27,65 @@ def novcs_commit(message):
2627

2728

2829
classTestVCS(TestCase):
29-
deftest_vcs(self):
30-
forttin [
30+
defdo_test_vcs(self,vcs):
31+
create_project=vcs["create_project"]
32+
commit=vcs["commit"]
33+
34+
runner=CliRunner()
35+
withrunner.isolated_filesystem():
36+
create_project("pyproject.toml")
37+
38+
write("changes/000.misc.rst","some change")
39+
40+
_vcs.stage_newsfile(os.getcwd(),"changes/000.misc.rst")
41+
42+
commit("commit 1")
43+
44+
branches=sorted(_vcs.get_remote_branches("."))
45+
self.assertIn(branches, [[], ["main","otherbranch"]])
46+
47+
ifvcs["name"]!="novcs":
48+
self.assertIn(
49+
_vcs.list_changed_files_compared_to_branch(".","main",False),
50+
[
51+
["changes/000.misc.rst"],
52+
[os.path.join("changes","000.misc.rst")],
53+
],
54+
)
55+
56+
write("changes/001.misc.rst","some change")
57+
_vcs.remove_files(
58+
os.getcwd(),
59+
[
60+
os.path.abspath(f)
61+
forfin ["changes/000.misc.rst","changes/001.misc.rst"]
62+
],
63+
)
64+
65+
deftest_git(self):
66+
self.do_test_vcs(
3167
{
3268
"name":"git",
3369
"create_project":test_check.create_project,
3470
"commit":test_check.commit,
3571
},
72+
)
73+
74+
@unittest.skipUnless(test_hg.hg_available,"requires 'mercurial' to be installed")
75+
deftest_mercurial(self):
76+
self.do_test_vcs(
3677
{
3778
"name":"mercurial",
3879
"create_project":test_hg.create_project,
3980
"commit":test_hg.commit,
4081
},
82+
)
83+
84+
deftest_novcs(self):
85+
self.do_test_vcs(
4186
{
4287
"name":"novcs",
4388
"create_project":novcs_create_project,
4489
"commit":novcs_commit,
4590
},
46-
]:
47-
withself.subTest(tt["name"]):
48-
create_project=tt["create_project"]
49-
commit=tt["commit"]
50-
51-
runner=CliRunner()
52-
withrunner.isolated_filesystem():
53-
create_project("pyproject.toml")
54-
55-
write("changes/000.misc.rst","some change")
56-
57-
_vcs.stage_newsfile(os.getcwd(),"changes/000.misc.rst")
58-
59-
commit("commit 1")
60-
61-
branches=sorted(_vcs.get_remote_branches("."))
62-
self.assertIn(branches, [[], ["main","otherbranch"]])
63-
64-
iftt["name"]!="novcs":
65-
self.assertIn(
66-
_vcs.list_changed_files_compared_to_branch(
67-
".","main",False
68-
),
69-
[
70-
["changes/000.misc.rst"],
71-
[os.path.join("changes","000.misc.rst")],
72-
],
73-
)
74-
75-
write("changes/001.misc.rst","some change")
76-
_vcs.remove_files(
77-
os.getcwd(),
78-
[
79-
os.path.abspath(f)
80-
forfin ["changes/000.misc.rst","changes/001.misc.rst"]
81-
],
82-
)
91+
)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp