summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2022-07-14 13:16:23 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2022-07-14 13:16:23 +0000
commiteebab08ecd6c247fa464f40934f852d63daba9bb (patch)
treeab61e7678c576d3489623464241ec67faf455964 /tests
parentReleasing debian version 2.19.0-1. (diff)
downloadpre-commit-eebab08ecd6c247fa464f40934f852d63daba9bb.tar.xz
pre-commit-eebab08ecd6c247fa464f40934f852d63daba9bb.zip
Merging upstream version 2.20.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--tests/commands/hook_impl_test.py36
-rw-r--r--tests/commands/run_test.py7
-rw-r--r--tests/conftest.py18
-rw-r--r--tests/error_handler_test.py6
-rw-r--r--tests/repository_test.py7
5 files changed, 55 insertions, 19 deletions
diff --git a/tests/commands/hook_impl_test.py b/tests/commands/hook_impl_test.py
index 3e20874..aa321da 100644
--- a/tests/commands/hook_impl_test.py
+++ b/tests/commands/hook_impl_test.py
@@ -154,6 +154,42 @@ def test_run_ns_commit_msg():
assert ns.commit_msg_filename == '.git/COMMIT_MSG'
+def test_run_ns_prepare_commit_msg_one_arg():
+ ns = hook_impl._run_ns(
+ 'prepare-commit-msg', False,
+ ('.git/COMMIT_MSG',), b'',
+ )
+ assert ns is not None
+ assert ns.hook_stage == 'prepare-commit-msg'
+ assert ns.color is False
+ assert ns.commit_msg_filename == '.git/COMMIT_MSG'
+
+
+def test_run_ns_prepare_commit_msg_two_arg():
+ ns = hook_impl._run_ns(
+ 'prepare-commit-msg', False,
+ ('.git/COMMIT_MSG', 'message'), b'',
+ )
+ assert ns is not None
+ assert ns.hook_stage == 'prepare-commit-msg'
+ assert ns.color is False
+ assert ns.commit_msg_filename == '.git/COMMIT_MSG'
+ assert ns.prepare_commit_message_source == 'message'
+
+
+def test_run_ns_prepare_commit_msg_three_arg():
+ ns = hook_impl._run_ns(
+ 'prepare-commit-msg', False,
+ ('.git/COMMIT_MSG', 'message', 'HEAD'), b'',
+ )
+ assert ns is not None
+ assert ns.hook_stage == 'prepare-commit-msg'
+ assert ns.color is False
+ assert ns.commit_msg_filename == '.git/COMMIT_MSG'
+ assert ns.prepare_commit_message_source == 'message'
+ assert ns.commit_object_name == 'HEAD'
+
+
def test_run_ns_post_commit():
ns = hook_impl._run_ns('post-commit', True, (), b'')
assert ns is not None
diff --git a/tests/commands/run_test.py b/tests/commands/run_test.py
index 085b063..2634c0c 100644
--- a/tests/commands/run_test.py
+++ b/tests/commands/run_test.py
@@ -810,7 +810,12 @@ def test_prepare_commit_msg_hook(cap_out, store, prepare_commit_msg_repo):
cap_out,
store,
prepare_commit_msg_repo,
- {'hook_stage': 'prepare-commit-msg', 'commit_msg_filename': filename},
+ {
+ 'hook_stage': 'prepare-commit-msg',
+ 'commit_msg_filename': filename,
+ 'prepare_commit_message_source': 'commit',
+ 'commit_object_name': 'HEAD',
+ },
expected_outputs=[b'Add "Signed off by:"', b'Passed'],
expected_ret=0,
stage=False,
diff --git a/tests/conftest.py b/tests/conftest.py
index b68a1d0..40c0c05 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -21,24 +21,6 @@ from testing.util import cwd
from testing.util import git_commit
-@pytest.fixture(autouse=True)
-def no_warnings(recwarn):
- yield
- warnings = []
- for warning in recwarn: # pragma: no cover
- message = str(warning.message)
- # ImportWarning: Not importing directory '...' missing __init__(.py)
- if not (
- isinstance(warning.message, ImportWarning) and
- message.startswith('Not importing directory ') and
- ' missing __init__' in message
- ):
- warnings.append(
- f'{warning.filename}:{warning.lineno} {message}',
- )
- assert not warnings
-
-
@pytest.fixture
def tempdir_factory(tmpdir):
class TmpdirFactory:
diff --git a/tests/error_handler_test.py b/tests/error_handler_test.py
index 31c71d2..47e2afa 100644
--- a/tests/error_handler_test.py
+++ b/tests/error_handler_test.py
@@ -45,9 +45,11 @@ def test_error_handler_fatal_error(mocked_log_and_exit):
r'Traceback \(most recent call last\):\n'
r' File ".+pre_commit.error_handler.py", line \d+, in error_handler\n'
r' yield\n'
+ r'( \^\^\^\^\^\n)?'
r' File ".+tests.error_handler_test.py", line \d+, '
r'in test_error_handler_fatal_error\n'
r' raise exc\n'
+ r'( \^\^\^\^\^\^\^\^\^\n)?'
r'(pre_commit\.errors\.)?FatalError: just a test\n',
)
pattern.assert_matches(mocked_log_and_exit.call_args[0][3])
@@ -69,9 +71,11 @@ def test_error_handler_uncaught_error(mocked_log_and_exit):
r'Traceback \(most recent call last\):\n'
r' File ".+pre_commit.error_handler.py", line \d+, in error_handler\n'
r' yield\n'
+ r'( \^\^\^\^\^\n)?'
r' File ".+tests.error_handler_test.py", line \d+, '
r'in test_error_handler_uncaught_error\n'
r' raise exc\n'
+ r'( \^\^\^\^\^\^\^\^\^\n)?'
r'ValueError: another test\n',
)
pattern.assert_matches(mocked_log_and_exit.call_args[0][3])
@@ -93,9 +97,11 @@ def test_error_handler_keyboardinterrupt(mocked_log_and_exit):
r'Traceback \(most recent call last\):\n'
r' File ".+pre_commit.error_handler.py", line \d+, in error_handler\n'
r' yield\n'
+ r'( \^\^\^\^\^\n)?'
r' File ".+tests.error_handler_test.py", line \d+, '
r'in test_error_handler_keyboardinterrupt\n'
r' raise exc\n'
+ r'( \^\^\^\^\^\^\^\^\^\n)?'
r'KeyboardInterrupt\n',
)
pattern.assert_matches(mocked_log_and_exit.call_args[0][3])
diff --git a/tests/repository_test.py b/tests/repository_test.py
index 3729ab1..11d452c 100644
--- a/tests/repository_test.py
+++ b/tests/repository_test.py
@@ -332,6 +332,13 @@ def test_run_a_ruby_hook(tempdir_factory, store):
)
+def test_run_a_ruby_hook_with_user_install_set(tempdir_factory, store, tmpdir):
+ gemrc = tmpdir.join('gemrc')
+ gemrc.write('gem: --user-install\n')
+ with envcontext((('GEMRC', str(gemrc)),)):
+ test_run_a_ruby_hook(tempdir_factory, store)
+
+
@xfailif_windows # pragma: win32 no cover
def test_run_versioned_ruby_hook(tempdir_factory, store):
_test_hook_repo(