88from locstat .utilities .core import derive_file_parser
99from locstat .data_structures .parse_modes import ParseMode
1010
11+
1112def _populate_directory (directory : Path ) -> None :
1213 directory .mkdir (parents = True , exist_ok = True )
1314
@@ -19,9 +20,7 @@ def _populate_directory(directory: Path) -> None:
1920 for d in (src , utils , tests , data ):
2021 d .mkdir (parents = True , exist_ok = True )
2122
22- (src / "main.py" ).write_text (
23- textwrap .dedent (
24- """
23+ (src / "main.py" ).write_text (textwrap .dedent ("""
2524 \" \" \"
2625 Entry point for the application.
2726 \" \" \"
@@ -38,14 +37,9 @@ def main():
3837
3938 if __name__ == "__main__":
4039 main()
41- """
42- ).strip ()
43- + "\n "
44- )
40+ """ ).strip () + "\n " )
4541
46- (utils / "math_utils.py" ).write_text (
47- textwrap .dedent (
48- """
42+ (utils / "math_utils.py" ).write_text (textwrap .dedent ("""
4943 \" \" \"
5044 Utility functions for math operations.
5145 \" \" \"
@@ -63,14 +57,9 @@ def add(a: int, b: int) -> int:
6357 The sum of a and b
6458 \" \" \"
6559 return a + b
66- """
67- ).strip ()
68- + "\n "
69- )
60+ """ ).strip () + "\n " )
7061
71- (tests / "test_math_utils.py" ).write_text (
72- textwrap .dedent (
73- """
62+ (tests / "test_math_utils.py" ).write_text (textwrap .dedent ("""
7463 import pytest
7564
7665 from src.utils.math_utils import add
@@ -83,14 +72,9 @@ def test_add_basic():
8372
8473 def test_add_negative_numbers():
8574 assert add(-1, -2) == -3
86- """
87- ).strip ()
88- + "\n "
89- )
75+ """ ).strip () + "\n " )
9076
91- (directory / "README.md" ).write_text (
92- textwrap .dedent (
93- """
77+ (directory / "README.md" ).write_text (textwrap .dedent ("""
9478 # Mock Project
9579
9680 This is a fake project structure used for testing filesystem behavior.
@@ -99,10 +83,7 @@ def test_add_negative_numbers():
9983 - Python code
10084 - Nested directories
10185 - Symlinks
102- """
103- ).strip ()
104- + "\n "
105- )
86+ """ ).strip () + "\n " )
10687
10788 (data / "sample.txt" ).write_text (
10889 "This is a sample data file.\n \n It has multiple lines.\n "
@@ -116,23 +97,31 @@ def test_add_negative_numbers():
11697 except (OSError , NotImplementedError ):
11798 pass
11899
100+
119101def test_parse_mode_consistency (mock_dir , mock_config ):
120102 _populate_directory (mock_dir )
121103
122- object .__setattr__ (mock_config , "symbol_mapping" , {"py" : (b"#" , None , None )})
104+ object .__setattr__ (mock_config , "symbol_mapping" , {"py" : (b"#" , None , None )})
123105
124106 outputs : dict [ParseMode , array .array ] = {}
125107 for parse_mode in ParseMode :
126- result : array .array = array .array ("L" , (0 ,0 ))
108+ result : array .array = array .array ("L" , (0 , 0 ))
127109 mock_config .parsing_mode = parse_mode
128- parse_directory (os .scandir (mock_dir ),
129- mock_config ,
130- result ,
131- - 1 ,
132- derive_file_parser (parse_mode ))
110+ parse_directory (
111+ os .scandir (mock_dir ),
112+ mock_config ,
113+ result ,
114+ - 1 ,
115+ derive_file_parser (parse_mode ),
116+ )
133117 outputs [parse_mode ] = result
134118
135- assert len (set (tuple (o ) for o in outputs .values ())) == 1 , \
136- " " .join (("Parsing modes produce different outputs" ,
137- "\n " .join (f"{ mode } : Total={ total } , LOC={ loc } "
138- for mode , (total , loc ) in outputs .items ())))
119+ assert len (set (tuple (o ) for o in outputs .values ())) == 1 , " " .join (
120+ (
121+ "Parsing modes produce different outputs" ,
122+ "\n " .join (
123+ f"{ mode } : Total={ total } , LOC={ loc } "
124+ for mode , (total , loc ) in outputs .items ()
125+ ),
126+ )
127+ )
0 commit comments