diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2020-06-14 09:11:21 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2020-06-14 09:11:21 +0000 |
commit | cc9f06b22c7665893e6958f7518a9e8d258e7d98 (patch) | |
tree | 19c3ef54ef886a32df2f3ed7be2f694d77b50bfc /tests/commands/run_test.py | |
parent | Adding upstream version 2.3.0. (diff) | |
download | pre-commit-cc9f06b22c7665893e6958f7518a9e8d258e7d98.tar.xz pre-commit-cc9f06b22c7665893e6958f7518a9e8d258e7d98.zip |
Adding upstream version 2.5.1.upstream/2.5.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/commands/run_test.py')
-rw-r--r-- | tests/commands/run_test.py | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/tests/commands/run_test.py b/tests/commands/run_test.py index c51bcff..2461ed5 100644 --- a/tests/commands/run_test.py +++ b/tests/commands/run_test.py @@ -939,7 +939,7 @@ def test_classifier_normalizes_filenames_on_windows_to_forward_slashes(tmpdir): tmpdir.join('a/b/c').ensure() with mock.patch.object(os, 'altsep', '/'): with mock.patch.object(os, 'sep', '\\'): - classifier = Classifier((r'a\b\c',)) + classifier = Classifier.from_config((r'a\b\c',), '', '^$') assert classifier.filenames == ['a/b/c'] @@ -947,7 +947,7 @@ def test_classifier_does_not_normalize_backslashes_non_windows(tmpdir): with mock.patch.object(os.path, 'lexists', return_value=True): with mock.patch.object(os, 'altsep', None): with mock.patch.object(os, 'sep', '/'): - classifier = Classifier((r'a/b\c',)) + classifier = Classifier.from_config((r'a/b\c',), '', '^$') assert classifier.filenames == [r'a/b\c'] @@ -1022,3 +1022,18 @@ def test_args_hook_only(cap_out, store, repo_with_passing_hook): run_opts(hook='do_not_commit'), ) assert b'identity-copy' not in printed + + +def test_skipped_without_any_setup_for_post_checkout(in_git_dir, store): + environ = {'_PRE_COMMIT_SKIP_POST_CHECKOUT': '1'} + opts = run_opts(hook_stage='post-checkout') + assert run(C.CONFIG_FILE, store, opts, environ=environ) == 0 + + +def test_pre_commit_env_variable_set(cap_out, store, repo_with_passing_hook): + args = run_opts() + environ: EnvironT = {} + ret, printed = _do_run( + cap_out, store, repo_with_passing_hook, args, environ, + ) + assert environ['PRE_COMMIT'] == '1' |