1
0
Fork 0

Adding upstream version 0.15.0.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-13 06:02:54 +01:00
parent a06c1515ef
commit d5d4d405a2
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
75 changed files with 1281 additions and 1555 deletions

View file

@ -10,18 +10,13 @@ import sys
import tempfile
from datetime import datetime
from uuid import uuid4
from unittest import TestCase
import arrow
try:
# python 2.x
from unittest2 import TestCase
except ImportError:
# python 3.x
from unittest import TestCase
from qa.shell import git, gitlint, RunningCommand
from qa.utils import DEFAULT_ENCODING, ustr
from qa.utils import DEFAULT_ENCODING
class BaseTestCase(TestCase):
@ -56,13 +51,14 @@ class BaseTestCase(TestCase):
def assertEqualStdout(self, output, expected): # pylint: disable=invalid-name
self.assertIsInstance(output, RunningCommand)
output = ustr(output.stdout)
output = output.stdout.decode(DEFAULT_ENCODING)
output = output.replace('\r', '')
self.assertMultiLineEqual(output, expected)
@classmethod
def generate_temp_path(cls):
return os.path.realpath("/tmp/gitlint-test-{0}".format(datetime.now().strftime("%Y%m%d-%H%M%S-%f")))
timestamp = datetime.now().strftime("%Y%m%d-%H%M%S-%f")
return os.path.realpath(f"/tmp/gitlint-test-{timestamp}")
@classmethod
def create_tmp_git_repo(cls):
@ -89,7 +85,7 @@ class BaseTestCase(TestCase):
@staticmethod
def create_file(parent_dir):
""" Creates a file inside a passed directory. Returns filename."""
test_filename = u"test-fïle-" + str(uuid4())
test_filename = "test-fïle-" + str(uuid4())
io.open(os.path.join(parent_dir, test_filename), 'a', encoding=DEFAULT_ENCODING).close()
return test_filename
@ -171,8 +167,8 @@ class BaseTestCase(TestCase):
@staticmethod
def get_system_info_dict():
""" Returns a dict with items related to system values logged by `gitlint --debug` """
expected_gitlint_version = gitlint("--version").replace("gitlint, version ", "").replace("\n", "")
expected_git_version = git("--version").replace("\n", "")
expected_gitlint_version = gitlint("--version").replace("gitlint, version ", "").strip()
expected_git_version = git("--version").strip()
return {'platform': platform.platform(), 'python_version': sys.version,
'git_version': expected_git_version, 'gitlint_version': expected_gitlint_version,
'GITLINT_USE_SH_LIB': BaseTestCase.GITLINT_USE_SH_LIB, 'DEFAULT_ENCODING': DEFAULT_ENCODING}