| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent a8a43fe commit 9fa1cee
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -40,6 +40,13 @@ def tearDown(self): | |||
| 40 | 40 | ||
| 41 | 41 | gc.collect() | |
| 42 | 42 | ||
| 43 | + def _assert_logged_for_popen(self, log_watcher, name, value): | ||
| 44 | + re_name = re.escape(name) | ||
| 45 | + re_value = re.escape(str(value)) | ||
| 46 | + re_line = re.compile(fr"DEBUG:git.cmd:Popen\(.*\b{re_name}={re_value}[,)]") | ||
| 47 | + match_attempts = [re_line.match(message) for message in log_watcher.output] | ||
| 48 | + self.assertTrue(any(match_attempts), repr(log_watcher.output)) | ||
| 49 | + | ||
| 43 | 50 | @mock.patch.object(Git, "execute") | |
| 44 | 51 | def test_call_process_calls_execute(self, git): | |
| 45 | 52 | git.return_value = "" | |
@@ -113,14 +120,9 @@ def test_it_uses_shell_or_not_as_specified(self, case): | |||
| 113 | 120 | def test_it_logs_if_it_uses_a_shell(self, case): | |
| 114 | 121 | """``shell=`` in the log message agrees with what is passed to `Popen`.""" | |
| 115 | 122 | value_in_call, value_from_class = case | |
| 116 | - | ||
| 117 | 123 | with self.assertLogs(cmd.log, level=logging.DEBUG) as log_watcher: | |
| 118 | 124 | mock_popen = self._do_shell_combo(value_in_call, value_from_class) | |
| 119 | - | ||
| 120 | - popen_shell_arg = mock_popen.call_args.kwargs["shell"] | ||
| 121 | - expected_message = re.compile(rf"DEBUG:git.cmd:Popen\(.*\bshell={popen_shell_arg}\b.*\)") | ||
| 122 | - match_attempts = [expected_message.fullmatch(message) for message in log_watcher.output] | ||
| 123 | - self.assertTrue(any(match_attempts), repr(log_watcher.output)) | ||
| 125 | + self._assert_logged_for_popen(log_watcher, "shell", mock_popen.call_args.kwargs["shell"]) | ||
| 124 | 126 | ||
| 125 | 127 | def test_it_executes_git_and_returns_result(self): | |
| 126 | 128 | self.assertRegex(self.git.execute(["git", "version"]), r"^git version [\d\.]{2}.*$") | |
| Back | FazBrowse Home | New Git URL |
0 commit comments