44
55from pathlib import Path
66
7+ import pytest
8+
79from ..auditor import collect_issues , compare_files , console , get_yaml_files , list_languages , print_warnings
810from ..dataclasses import ComparisonResult , RuleDifference , RuleInfo
911
1012
13+ @pytest .fixture ()
14+ def fixed_console_width ():
15+ """Pin Rich console to 80 columns so golden-file comparisons are portable."""
16+ old = console .width
17+ console .width = 80
18+ yield
19+ console .width = old
20+
21+
1122def make_rule (name : str , tag : str , line : int , raw : str ) -> RuleInfo :
1223 return RuleInfo (
1324 name = name ,
@@ -155,7 +166,7 @@ def test_get_yaml_files_includes_region(tmp_path) -> None:
155166 (region_dir / "unicode.yaml" ).write_text ("---" , encoding = "utf-8" )
156167
157168 files = get_yaml_files (lang_dir , region_dir )
158- assert set (files ) == {"base.yaml" , "SharedRules/shared.yaml" , "unicode.yaml" }
169+ assert set (files ) == {Path ( "base.yaml" ), Path ( "SharedRules/shared.yaml" ), Path ( "unicode.yaml" ) }
159170
160171
161172def test_list_languages_includes_region_codes (tmp_path ) -> None :
@@ -183,9 +194,11 @@ def test_list_languages_includes_region_codes(tmp_path) -> None:
183194 assert "zz-aa" in output
184195
185196
186- def test_print_warnings_omits_snippets_when_not_verbose () -> None :
197+ def test_print_warnings_omits_snippets_when_not_verbose (fixed_console_width ) -> None :
187198 """
188199 Ensure the print_warnings output matches the non-verbose golden snapshot.
200+
201+ Uses pytest fixture for console width.
189202 """
190203 base_dir = Path (__file__ ).parent
191204 fixtures_dir = base_dir / "fixtures"
@@ -202,9 +215,11 @@ def test_print_warnings_omits_snippets_when_not_verbose() -> None:
202215 assert output == golden_path .read_text (encoding = "utf-8" )
203216
204217
205- def test_print_warnings_includes_snippets_when_verbose () -> None :
218+ def test_print_warnings_includes_snippets_when_verbose (fixed_console_width ) -> None :
206219 """
207220 Ensure the print_warnings output matches the verbose golden snapshot.
221+
222+ Uses pytest fixture for console width.
208223 """
209224 base_dir = Path (__file__ ).parent
210225 fixtures_dir = base_dir / "fixtures"
0 commit comments