From 9262e31316a16180044e0e28a2740238f8aef5c4 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 19 Jun 2022 09:03:36 +0200 Subject: Merging upstream version 4.3.0. Signed-off-by: Daniel Baumann --- tests/check_added_large_files_test.py | 2 ++ tests/check_ast_test.py | 2 ++ tests/check_builtin_literals_test.py | 2 ++ tests/check_byte_order_marker_test.py | 2 ++ tests/check_case_conflict_test.py | 2 ++ tests/check_docstring_first_test.py | 8 +++++--- tests/check_executables_have_shebangs_test.py | 2 ++ tests/check_json_test.py | 2 ++ tests/check_merge_conflict_test.py | 14 +++++++++++--- tests/check_shebang_scripts_are_executable_test.py | 2 ++ tests/check_symlinks_test.py | 2 ++ tests/check_toml_test.py | 2 ++ tests/check_vcs_permalinks_test.py | 2 ++ tests/check_xml_test.py | 2 ++ tests/check_yaml_test.py | 2 ++ tests/conftest.py | 2 ++ tests/debug_statement_hook_test.py | 6 +++++- tests/destroyed_symlinks_test.py | 2 ++ tests/detect_aws_credentials_test.py | 2 ++ tests/detect_private_key_test.py | 2 ++ tests/end_of_file_fixer_test.py | 2 ++ tests/file_contents_sorter_test.py | 2 ++ tests/fix_byte_order_marker_test.py | 2 ++ tests/fix_encoding_pragma_test.py | 2 ++ tests/forbid_new_submodules_test.py | 2 ++ tests/mixed_line_ending_test.py | 2 ++ tests/no_commit_to_branch_test.py | 2 ++ tests/pretty_format_json_test.py | 2 ++ tests/readme_test.py | 2 ++ tests/removed_test.py | 2 ++ tests/requirements_txt_fixer_test.py | 2 ++ tests/sort_simple_yaml_test.py | 2 ++ tests/string_fixer_test.py | 2 ++ tests/tests_should_end_in_test_test.py | 7 +++++++ tests/trailing_whitespace_fixer_test.py | 2 ++ tests/util_test.py | 2 ++ 36 files changed, 92 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/check_added_large_files_test.py b/tests/check_added_large_files_test.py index c16bf5a..54c4e68 100644 --- a/tests/check_added_large_files_test.py +++ b/tests/check_added_large_files_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import shutil import pytest diff --git a/tests/check_ast_test.py b/tests/check_ast_test.py index 686fd11..6243966 100644 --- a/tests/check_ast_test.py +++ b/tests/check_ast_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from pre_commit_hooks.check_ast import main from testing.util import get_resource_path diff --git a/tests/check_builtin_literals_test.py b/tests/check_builtin_literals_test.py index e936798..1b18257 100644 --- a/tests/check_builtin_literals_test.py +++ b/tests/check_builtin_literals_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import ast import pytest diff --git a/tests/check_byte_order_marker_test.py b/tests/check_byte_order_marker_test.py index 4c40247..909a39b 100644 --- a/tests/check_byte_order_marker_test.py +++ b/tests/check_byte_order_marker_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from pre_commit_hooks import check_byte_order_marker diff --git a/tests/check_case_conflict_test.py b/tests/check_case_conflict_test.py index d9211b5..a914f45 100644 --- a/tests/check_case_conflict_test.py +++ b/tests/check_case_conflict_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import sys import pytest diff --git a/tests/check_docstring_first_test.py b/tests/check_docstring_first_test.py index ed5c08e..8bafae8 100644 --- a/tests/check_docstring_first_test.py +++ b/tests/check_docstring_first_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pytest from pre_commit_hooks.check_docstring_first import check_docstring_first @@ -15,7 +17,7 @@ TESTS = ( b'from __future__ import unicode_literals\n' b'"foo"\n', 1, - '{filename}:2 Module docstring appears after code ' + '{filename}:2: Module docstring appears after code ' '(code seen on line 1).\n', ), # Test double docstring @@ -24,7 +26,7 @@ TESTS = ( b'from __future__ import absolute_import\n' b'"fake docstring"\n', 1, - '{filename}:3 Multiple module docstrings ' + '{filename}:3: Multiple module docstrings ' '(first docstring on line 1).\n', ), # Test multiple lines of code above @@ -33,7 +35,7 @@ TESTS = ( b'import sys\n' b'"docstring"\n', 1, - '{filename}:3 Module docstring appears after code ' + '{filename}:3: Module docstring appears after code ' '(code seen on line 1).\n', ), # String literals in expressions are ok. diff --git a/tests/check_executables_have_shebangs_test.py b/tests/check_executables_have_shebangs_test.py index 5703ede..82d03e3 100644 --- a/tests/check_executables_have_shebangs_test.py +++ b/tests/check_executables_have_shebangs_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import os import sys diff --git a/tests/check_json_test.py b/tests/check_json_test.py index 3ec67f1..53e1f52 100644 --- a/tests/check_json_test.py +++ b/tests/check_json_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pytest from pre_commit_hooks.check_json import main diff --git a/tests/check_merge_conflict_test.py b/tests/check_merge_conflict_test.py index 79c1b11..76c4283 100644 --- a/tests/check_merge_conflict_test.py +++ b/tests/check_merge_conflict_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import os import shutil @@ -99,8 +101,14 @@ def repository_pending_merge(tmpdir): @pytest.mark.usefixtures('f1_is_a_conflict_file') -def test_merge_conflicts_git(): +def test_merge_conflicts_git(capsys): assert main(['f1']) == 1 + out, _ = capsys.readouterr() + assert out == ( + "f1:1: Merge conflict string '<<<<<<<' found\n" + "f1:3: Merge conflict string '=======' found\n" + "f1:5: Merge conflict string '>>>>>>>' found\n" + ) @pytest.mark.parametrize( @@ -137,7 +145,7 @@ def test_care_when_assumed_merge(tmpdir): assert main([str(f.realpath()), '--assume-in-merge']) == 1 -def test_worktree_merge_conflicts(f1_is_a_conflict_file, tmpdir): +def test_worktree_merge_conflicts(f1_is_a_conflict_file, tmpdir, capsys): worktree = tmpdir.join('worktree') cmd_output('git', 'worktree', 'add', str(worktree)) with worktree.as_cwd(): @@ -146,4 +154,4 @@ def test_worktree_merge_conflicts(f1_is_a_conflict_file, tmpdir): ) msg = f1_is_a_conflict_file.join('.git/worktrees/worktree/MERGE_MSG') assert msg.exists() - test_merge_conflicts_git() + test_merge_conflicts_git(capsys) diff --git a/tests/check_shebang_scripts_are_executable_test.py b/tests/check_shebang_scripts_are_executable_test.py index 9e78b06..e4bd07c 100644 --- a/tests/check_shebang_scripts_are_executable_test.py +++ b/tests/check_shebang_scripts_are_executable_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import os import pytest diff --git a/tests/check_symlinks_test.py b/tests/check_symlinks_test.py index 07c1168..e2c2c78 100644 --- a/tests/check_symlinks_test.py +++ b/tests/check_symlinks_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import os import pytest diff --git a/tests/check_toml_test.py b/tests/check_toml_test.py index c7251eb..d594f81 100644 --- a/tests/check_toml_test.py +++ b/tests/check_toml_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from pre_commit_hooks.check_toml import main diff --git a/tests/check_vcs_permalinks_test.py b/tests/check_vcs_permalinks_test.py index ad59151..01ce94d 100644 --- a/tests/check_vcs_permalinks_test.py +++ b/tests/check_vcs_permalinks_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from pre_commit_hooks.check_vcs_permalinks import main diff --git a/tests/check_xml_test.py b/tests/check_xml_test.py index 357bad6..767619f 100644 --- a/tests/check_xml_test.py +++ b/tests/check_xml_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pytest from pre_commit_hooks.check_xml import main diff --git a/tests/check_yaml_test.py b/tests/check_yaml_test.py index 1a017a1..54eb16e 100644 --- a/tests/check_yaml_test.py +++ b/tests/check_yaml_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pytest from pre_commit_hooks.check_yaml import main diff --git a/tests/conftest.py b/tests/conftest.py index f92cfc1..807f15b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pytest from pre_commit_hooks.util import cmd_output diff --git a/tests/debug_statement_hook_test.py b/tests/debug_statement_hook_test.py index 428421a..5a8e0bb 100644 --- a/tests/debug_statement_hook_test.py +++ b/tests/debug_statement_hook_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import ast from pre_commit_hooks.debug_statement_hook import Debug @@ -53,7 +55,9 @@ def test_non_utf8_file(tmpdir): assert main((str(f_py),)) == 0 -def test_py37_breakpoint(tmpdir): +def test_py37_breakpoint(tmpdir, capsys): f_py = tmpdir.join('f.py') f_py.write('def f():\n breakpoint()\n') assert main((str(f_py),)) == 1 + out, _ = capsys.readouterr() + assert out == f'{f_py}:2:4: breakpoint called\n' diff --git a/tests/destroyed_symlinks_test.py b/tests/destroyed_symlinks_test.py index cde06cf..39c474a 100644 --- a/tests/destroyed_symlinks_test.py +++ b/tests/destroyed_symlinks_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import os import subprocess diff --git a/tests/detect_aws_credentials_test.py b/tests/detect_aws_credentials_test.py index 7212509..afda47a 100644 --- a/tests/detect_aws_credentials_test.py +++ b/tests/detect_aws_credentials_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from unittest.mock import patch import pytest diff --git a/tests/detect_private_key_test.py b/tests/detect_private_key_test.py index d2c724f..41f8bae 100644 --- a/tests/detect_private_key_test.py +++ b/tests/detect_private_key_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pytest from pre_commit_hooks.detect_private_key import main diff --git a/tests/end_of_file_fixer_test.py b/tests/end_of_file_fixer_test.py index 60b9e82..8a5d889 100644 --- a/tests/end_of_file_fixer_test.py +++ b/tests/end_of_file_fixer_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import io import pytest diff --git a/tests/file_contents_sorter_test.py b/tests/file_contents_sorter_test.py index 15f1134..5e79e40 100644 --- a/tests/file_contents_sorter_test.py +++ b/tests/file_contents_sorter_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pytest from pre_commit_hooks.file_contents_sorter import FAIL diff --git a/tests/fix_byte_order_marker_test.py b/tests/fix_byte_order_marker_test.py index da150e3..d7a6599 100644 --- a/tests/fix_byte_order_marker_test.py +++ b/tests/fix_byte_order_marker_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from pre_commit_hooks import fix_byte_order_marker diff --git a/tests/fix_encoding_pragma_test.py b/tests/fix_encoding_pragma_test.py index f3afa09..98557e9 100644 --- a/tests/fix_encoding_pragma_test.py +++ b/tests/fix_encoding_pragma_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import io import pytest diff --git a/tests/forbid_new_submodules_test.py b/tests/forbid_new_submodules_test.py index 0326d94..058a329 100644 --- a/tests/forbid_new_submodules_test.py +++ b/tests/forbid_new_submodules_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import os import subprocess from unittest import mock diff --git a/tests/mixed_line_ending_test.py b/tests/mixed_line_ending_test.py index f1c2641..a7e7971 100644 --- a/tests/mixed_line_ending_test.py +++ b/tests/mixed_line_ending_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pytest from pre_commit_hooks.mixed_line_ending import main diff --git a/tests/no_commit_to_branch_test.py b/tests/no_commit_to_branch_test.py index 9fcb580..eaae5e6 100644 --- a/tests/no_commit_to_branch_test.py +++ b/tests/no_commit_to_branch_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pytest from pre_commit_hooks.no_commit_to_branch import is_on_branch diff --git a/tests/pretty_format_json_test.py b/tests/pretty_format_json_test.py index 7fda23b..5ded724 100644 --- a/tests/pretty_format_json_test.py +++ b/tests/pretty_format_json_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import os import shutil diff --git a/tests/readme_test.py b/tests/readme_test.py index 7df7fcf..038868d 100644 --- a/tests/readme_test.py +++ b/tests/readme_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from pre_commit_hooks.check_yaml import yaml diff --git a/tests/removed_test.py b/tests/removed_test.py index d635eb1..cd66957 100644 --- a/tests/removed_test.py +++ b/tests/removed_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pytest from pre_commit_hooks.removed import main diff --git a/tests/requirements_txt_fixer_test.py b/tests/requirements_txt_fixer_test.py index e3c6ed5..b725afa 100644 --- a/tests/requirements_txt_fixer_test.py +++ b/tests/requirements_txt_fixer_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pytest from pre_commit_hooks.requirements_txt_fixer import FAIL diff --git a/tests/sort_simple_yaml_test.py b/tests/sort_simple_yaml_test.py index a682c15..6cbda85 100644 --- a/tests/sort_simple_yaml_test.py +++ b/tests/sort_simple_yaml_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import os import pytest diff --git a/tests/string_fixer_test.py b/tests/string_fixer_test.py index 6ddb0ac..9dd7315 100644 --- a/tests/string_fixer_test.py +++ b/tests/string_fixer_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import textwrap import pytest diff --git a/tests/tests_should_end_in_test_test.py b/tests/tests_should_end_in_test_test.py index 4df2963..2b5a0de 100644 --- a/tests/tests_should_end_in_test_test.py +++ b/tests/tests_should_end_in_test_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from pre_commit_hooks.tests_should_end_in_test import main @@ -41,3 +43,8 @@ def test_main_not_django_fails(): def test_main_django_fails(): ret = main(['--django', 'foo_test.py', 'test_bar.py', 'test_baz.py']) assert ret == 1 + + +def test_main_pytest_test_first(): + assert main(['--pytest-test-first', 'test_foo.py']) == 0 + assert main(['--pytest-test-first', 'foo_test.py']) == 1 diff --git a/tests/trailing_whitespace_fixer_test.py b/tests/trailing_whitespace_fixer_test.py index bb3b62d..c07497a 100644 --- a/tests/trailing_whitespace_fixer_test.py +++ b/tests/trailing_whitespace_fixer_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pytest from pre_commit_hooks.trailing_whitespace_fixer import main diff --git a/tests/util_test.py b/tests/util_test.py index 7f48816..92473e5 100644 --- a/tests/util_test.py +++ b/tests/util_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pytest from pre_commit_hooks.util import CalledProcessError -- cgit v1.2.3