From 29dc99c21faefb1530b19abbd2a090fb07a169b1 Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Mon, 12 Sep 2022 22:47:31 +0300 Subject: [PATCH] tidy bad git messages in tests --- core/TESTS/test_imports.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/core/TESTS/test_imports.py b/core/TESTS/test_imports.py index 52b1fd4..48e324e 100644 --- a/core/TESTS/test_imports.py +++ b/core/TESTS/test_imports.py @@ -152,22 +152,24 @@ class SubprocessTest(TestCase): TROGGLE_PATH = Path(settings.REPOS_ROOT_PATH) / "troggle" for cwd in [settings.SURVEX_DATA, settings.EXPOWEB, settings.DRAWINGS_DATA, TROGGLE_PATH]: sp = subprocess.run([settings.GIT, "status"], cwd=cwd, capture_output=True, text=True) - scwd = str(cwd) - # print(scwd + ":\n\n#" + sp.stderr + '\n\n#' + sp.stdout + '\n\n# return code: ' + str(sp.returncode)) + print(f'git output: {cwd}:\n # {sp.stderr=}\n # {sp.stdout=} \n # return code: {str(sp.returncode)}') if sp.returncode != 0: - print(scwd + ":\n\n" + sp.stderr + '\n\n' + sp.stdout + '\n\nreturn code: ' + str(sp.returncode)) - self.assertTrue( sp.returncode == 0, f'{scwd} - git is unhappy') + print(f'git output: {cwd}:\n # {sp.stderr=}\n # {sp.stdout=} \n # return code: {str(sp.returncode)}') + + self.assertTrue( sp.returncode == 0, f'{cwd} - git is unhappy') content = sp.stdout ph = r'Your branch is up[ -]to[ -]date' phmatch = re.search(ph, content) - self.assertIsNotNone(phmatch, f"{scwd} - Failed to find expected git output: '" + ph +"'") + msg = f'{cwd} - Failed to find expected git output: "{ph}"' + self.assertIsNotNone(phmatch, msg) ph1 = r'no changes added to commit' phmatch1 = re.search(ph1, content) ph2 = r'nothing to commit' phmatch2 = re.search(ph2, content) phmatch = phmatch1 or phmatch2 - self.assertIsNotNone(phmatch, f"{scwd} - Failed to find expected git output: {ph1} or {ph2}") + msg = f'{cwd} - Failed to find expected git output: "{ph1}" or "{ph2}"' + self.assertIsNotNone(phmatch, msg)