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

Commit0f19fb0

Browse files
committed
Fix tests so they don't try to run "g"
Both new shell-related tests were causing the code under test tosplit "git" into ["g", "i", "t"] and thus causing the code undertest to attempt to execute a "g" command. This passes the commandas a one-element list of strings rather than as a string, whichavoids this on all operating systems regardless of whether the codeunder test has a bug being tested for.This would not occur on Windows, which does not iterate commands oftype str character-by-character even when the command is runwithout a shell. But it did happen on other systems.Most of the time, the benefit of using a command that actually runs"git" rather than "g" is the avoidance of confusion in the errormessage. But this is also important because it is possible for theuser who runs the tests to have a "g" command, in which case itcould be very inconvenient, or even unsafe, to run "g". This shouldbe avoided even when the code under test has a bug that causes ashell to be used when it shouldn't or not used when it should, sohaving separate commands (list and str) per test case parameterswould not be a sufficient solution: it would only guard againstrunning "g" when a bug in the code under test were absent.
1 parentaa5e2f6 commit0f19fb0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

‎test/test_git.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def test_it_uses_shell_or_not_as_specified(self, case, mock_popen):
9595
withmock.patch.object(Git,"USE_SHELL",value_from_class):
9696
withcontextlib.suppress(GitCommandError):
9797
self.git.execute(
98-
"git",# No args, so it runs with or without a shell, on all OSes.
98+
["git"],# No args, so it runs with or without a shell, on all OSes.
9999
shell=value_in_call,
100100
)
101101

@@ -112,7 +112,7 @@ def test_it_logs_if_it_uses_a_shell(self, case, mock_popen):
112112
withmock.patch.object(Git,"USE_SHELL",value_from_class):
113113
withcontextlib.suppress(GitCommandError):
114114
self.git.execute(
115-
"git",# No args, so it runs with or without a shell, on all OSes.
115+
["git"],# No args, so it runs with or without a shell, on all OSes.
116116
shell=value_in_call,
117117
)
118118

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp