From 1d82b7eaf98e695689a7dc10bd308030e3c13eea Mon Sep 17 00:00:00 2001 From: Ondrej Nosek Date: Sat, 1 Apr 2023 01:34:34 +0200 Subject: [PATCH] Fix unittests for `clone` and pre-push hook script Signed-off-by: Ondrej Nosek --- tests/commands/test_clone.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/commands/test_clone.py b/tests/commands/test_clone.py index 6ef1300..85fdfd1 100644 --- a/tests/commands/test_clone.py +++ b/tests/commands/test_clone.py @@ -1,5 +1,6 @@ import os import shutil +import sys import tempfile import git @@ -110,9 +111,10 @@ class CommandCloneTestCase(CommandTestCase): moduledir = os.path.join(self.path, self.module) self.assertTrue(os.path.isfile(os.path.join(moduledir, '.git/hooks/pre-push'))) + clonned_by = os.path.basename(sys.argv[0]) with open(os.path.join(moduledir, '.git/hooks/pre-push')) as git_hook_script: content = git_hook_script.read() - pattern = '__main__.py pre-push-check "$local_sha"' + pattern = '{0} pre-push-check "$local_sha"'.format(clonned_by) self.assertIn(pattern, content) shutil.rmtree(altpath) @@ -132,9 +134,11 @@ class CommandCloneTestCase(CommandTestCase): moduledir = os.path.join(self.path, self.module) self.assertTrue(os.path.isfile(os.path.join(moduledir, '.git/hooks/pre-push'))) + clonned_by = os.path.basename(sys.argv[0]) with open(os.path.join(moduledir, '.git/hooks/pre-push')) as git_hook_script: content = git_hook_script.read() - pattern = '__main__.py -C "/home/conf/rhpkg.conf" pre-push-check "$local_sha"' + pattern = '{0} -C "/home/conf/rhpkg.conf" pre-push-check ' \ + '"$local_sha"'.format(clonned_by) self.assertIn(pattern, content) shutil.rmtree(altpath) -- 2.39.2