@@ -72,8 +72,12 @@ def test_compile_commands_explicit(tmp_path):
7272 db_dir = tmp_path / "build"
7373 db_dir .mkdir ()
7474 (db_dir / "compile_commands.json" ).write_text ("[]" )
75- with patch ("cpp_linter_hooks.clang_tidy.subprocess.run" , return_value = _MOCK_RUN ) as mock_run , \
76- patch ("cpp_linter_hooks.clang_tidy.resolve_install" ):
75+ with (
76+ patch (
77+ "cpp_linter_hooks.clang_tidy.subprocess.run" , return_value = _MOCK_RUN
78+ ) as mock_run ,
79+ patch ("cpp_linter_hooks.clang_tidy.resolve_install" ),
80+ ):
7781 run_clang_tidy ([f"--compile-commands={ db_dir } " , "dummy.cpp" ])
7882 cmd = mock_run .call_args [0 ][0 ]
7983 assert "-p" in cmd
@@ -85,8 +89,12 @@ def test_compile_commands_auto_detect(tmp_path, monkeypatch):
8589 build_dir = tmp_path / "build"
8690 build_dir .mkdir ()
8791 (build_dir / "compile_commands.json" ).write_text ("[]" )
88- with patch ("cpp_linter_hooks.clang_tidy.subprocess.run" , return_value = _MOCK_RUN ) as mock_run , \
89- patch ("cpp_linter_hooks.clang_tidy.resolve_install" ):
92+ with (
93+ patch (
94+ "cpp_linter_hooks.clang_tidy.subprocess.run" , return_value = _MOCK_RUN
95+ ) as mock_run ,
96+ patch ("cpp_linter_hooks.clang_tidy.resolve_install" ),
97+ ):
9098 run_clang_tidy (["dummy.cpp" ])
9199 cmd = mock_run .call_args [0 ][0 ]
92100 assert "-p" in cmd
@@ -99,8 +107,12 @@ def test_compile_commands_auto_detect_fallback(tmp_path, monkeypatch):
99107 out_dir = tmp_path / "out"
100108 out_dir .mkdir ()
101109 (out_dir / "compile_commands.json" ).write_text ("[]" )
102- with patch ("cpp_linter_hooks.clang_tidy.subprocess.run" , return_value = _MOCK_RUN ) as mock_run , \
103- patch ("cpp_linter_hooks.clang_tidy.resolve_install" ):
110+ with (
111+ patch (
112+ "cpp_linter_hooks.clang_tidy.subprocess.run" , return_value = _MOCK_RUN
113+ ) as mock_run ,
114+ patch ("cpp_linter_hooks.clang_tidy.resolve_install" ),
115+ ):
104116 run_clang_tidy (["dummy.cpp" ])
105117 cmd = mock_run .call_args [0 ][0 ]
106118 assert "-p" in cmd
@@ -109,8 +121,12 @@ def test_compile_commands_auto_detect_fallback(tmp_path, monkeypatch):
109121
110122def test_compile_commands_none (tmp_path , monkeypatch ):
111123 monkeypatch .chdir (tmp_path )
112- with patch ("cpp_linter_hooks.clang_tidy.subprocess.run" , return_value = _MOCK_RUN ) as mock_run , \
113- patch ("cpp_linter_hooks.clang_tidy.resolve_install" ):
124+ with (
125+ patch (
126+ "cpp_linter_hooks.clang_tidy.subprocess.run" , return_value = _MOCK_RUN
127+ ) as mock_run ,
128+ patch ("cpp_linter_hooks.clang_tidy.resolve_install" ),
129+ ):
114130 run_clang_tidy (["dummy.cpp" ])
115131 cmd = mock_run .call_args [0 ][0 ]
116132 assert "-p" not in cmd
@@ -122,8 +138,12 @@ def test_compile_commands_conflict_guard(tmp_path, monkeypatch):
122138 build_dir = tmp_path / "build"
123139 build_dir .mkdir ()
124140 (build_dir / "compile_commands.json" ).write_text ("[]" )
125- with patch ("cpp_linter_hooks.clang_tidy.subprocess.run" , return_value = _MOCK_RUN ) as mock_run , \
126- patch ("cpp_linter_hooks.clang_tidy.resolve_install" ):
141+ with (
142+ patch (
143+ "cpp_linter_hooks.clang_tidy.subprocess.run" , return_value = _MOCK_RUN
144+ ) as mock_run ,
145+ patch ("cpp_linter_hooks.clang_tidy.resolve_install" ),
146+ ):
127147 run_clang_tidy (["-p" , "./custom" , "dummy.cpp" ])
128148 cmd = mock_run .call_args [0 ][0 ]
129149 assert cmd .count ("-p" ) == 1
@@ -136,8 +156,12 @@ def test_compile_commands_no_flag(tmp_path, monkeypatch):
136156 build_dir = tmp_path / "build"
137157 build_dir .mkdir ()
138158 (build_dir / "compile_commands.json" ).write_text ("[]" )
139- with patch ("cpp_linter_hooks.clang_tidy.subprocess.run" , return_value = _MOCK_RUN ) as mock_run , \
140- patch ("cpp_linter_hooks.clang_tidy.resolve_install" ):
159+ with (
160+ patch (
161+ "cpp_linter_hooks.clang_tidy.subprocess.run" , return_value = _MOCK_RUN
162+ ) as mock_run ,
163+ patch ("cpp_linter_hooks.clang_tidy.resolve_install" ),
164+ ):
141165 run_clang_tidy (["--no-compile-commands" , "dummy.cpp" ])
142166 cmd = mock_run .call_args [0 ][0 ]
143167 assert "-p" not in cmd
@@ -165,8 +189,12 @@ def test_compile_commands_explicit_with_p_conflict(tmp_path, capsys):
165189 db_dir = tmp_path / "build"
166190 db_dir .mkdir ()
167191 (db_dir / "compile_commands.json" ).write_text ("[]" )
168- with patch ("cpp_linter_hooks.clang_tidy.subprocess.run" , return_value = _MOCK_RUN ) as mock_run , \
169- patch ("cpp_linter_hooks.clang_tidy.resolve_install" ):
192+ with (
193+ patch (
194+ "cpp_linter_hooks.clang_tidy.subprocess.run" , return_value = _MOCK_RUN
195+ ) as mock_run ,
196+ patch ("cpp_linter_hooks.clang_tidy.resolve_install" ),
197+ ):
170198 run_clang_tidy ([f"--compile-commands={ db_dir } " , "-p" , "./other" , "dummy.cpp" ])
171199 captured = capsys .readouterr ()
172200 assert "Warning" in captured .err
0 commit comments