11"""Tests for the `replace-docs` subcommand."""
22
33from argparse import ArgumentParser , Namespace
4- from subprocess import CalledProcessError # noqa: S404. We invoke cli tools
4+ from subprocess import CalledProcessError
55
66import pytest
77import pytest_mock
1010from pre_commit_terraform .terraform_docs_replace import (
1111 invoke_cli_app ,
1212 populate_argument_parser ,
13- )
14- from pre_commit_terraform .terraform_docs_replace import (
1513 subprocess as replace_docs_subprocess_mod ,
1614)
1715
@@ -26,7 +24,8 @@ def test_arg_parser_populated() -> None:
2624def test_check_is_deprecated () -> None :
2725 """Verify that `replace-docs` shows a deprecation warning."""
2826 deprecation_msg_regex = (
29- r'^`terraform_docs_replace` hook is DEPRECATED\.' + 'For migration.*$'
27+ r'^`terraform_docs_replace` hook is DEPRECATED\.'
28+ 'For migration.*$'
3029 )
3130 with pytest .warns (UserWarning , match = deprecation_msg_regex ):
3231 # not `pytest.deprecated_call()` due to this being a user warning
@@ -71,10 +70,10 @@ def test_check_is_deprecated() -> None:
7170 'pre_commit_terraform.terraform_docs_replace' ,
7271)
7372def test_control_flow_positive (
74- expected_cmds : list [str ],
75- mocker : pytest_mock .MockerFixture ,
76- monkeypatch : pytest .MonkeyPatch ,
77- parsed_cli_args : Namespace ,
73+ expected_cmds : list [str ],
74+ mocker : pytest_mock .MockerFixture ,
75+ monkeypatch : pytest .MonkeyPatch ,
76+ parsed_cli_args : Namespace ,
7877) -> None :
7978 """Check that the subcommand's happy path works."""
8079 check_call_mock = mocker .Mock ()
@@ -84,10 +83,10 @@ def test_control_flow_positive(
8483 check_call_mock ,
8584 )
8685
87- assert invoke_cli_app ( parsed_cli_args ) == ReturnCode . OK
86+ assert ReturnCode . OK == invoke_cli_app ( parsed_cli_args )
8887
8988 executed_commands = [
90- cmd for ((cmd ,), _shell ) in check_call_mock .call_args_list
89+ cmd for ((cmd , ), _shell ) in check_call_mock .call_args_list
9190 ]
9291
9392 assert len (expected_cmds ) == check_call_mock .call_count
@@ -99,8 +98,8 @@ def test_control_flow_positive(
9998 'pre_commit_terraform.terraform_docs_replace' ,
10099)
101100def test_control_flow_negative (
102- mocker : pytest_mock .MockerFixture ,
103- monkeypatch : pytest .MonkeyPatch ,
101+ mocker : pytest_mock .MockerFixture ,
102+ monkeypatch : pytest .MonkeyPatch ,
104103) -> None :
105104 """Check that the subcommand's error processing works."""
106105 parsed_cli_args = Namespace (
@@ -119,6 +118,6 @@ def test_control_flow_negative(
119118 check_call_mock ,
120119 )
121120
122- assert invoke_cli_app ( parsed_cli_args ) == ReturnCode . ERROR
123- # We call cli tools, of course we use shell=True
124- check_call_mock .assert_called_once_with (expected_cmd , shell = True ) # noqa: S604
121+ assert ReturnCode . ERROR == invoke_cli_app ( parsed_cli_args )
122+
123+ check_call_mock .assert_called_once_with (expected_cmd , shell = True )
0 commit comments