@@ -12,6 +12,26 @@ def region_test_case(*, rst: str, regions: list[Region], id: str = ""):
1212 return pytest .param (rst , regions , id = id )
1313
1414
15+ def region (
16+ kind : str ,
17+ name : str ,
18+ * ,
19+ start : int ,
20+ end : int = 0 ,
21+ end_main : int = 0 ,
22+ end_total : int = 0 ,
23+ ) -> Region :
24+ """Helper to create a Region with end_main and end_total defaulting to end."""
25+ assert end or (end_main and end_total ), (
26+ "Either end or both end_main and end_total must be provided"
27+ )
28+ if not end_main :
29+ end_main = end
30+ if not end_total :
31+ end_total = end
32+ return Region (kind = kind , name = name , start = start , end_main = end_main , end_total = end_total )
33+
34+
1535TEST_CASES = [
1636 # The `contents::` directive makes unnumbered paragraphs.
1737 region_test_case (
@@ -61,7 +81,9 @@ def region_test_case(*, rst: str, regions: list[Region], id: str = ""):
6181
6282 23This section references :mod:`mymodule` which is fine.
6383 """ ,
64- regions = [Region (kind = "module" , name = "mymodule" , start = 1 , end_main = 18 , end_total = 18 )],
84+ regions = [
85+ region ("module" , "mymodule" , start = 1 , end = 18 ),
86+ ],
6587 ),
6688 region_test_case (
6789 id = "multiple-functions" ,
@@ -77,34 +99,34 @@ def region_test_case(*, rst: str, regions: list[Region], id: str = ""):
7799 This is a family of similar functions.
78100 """ ,
79101 regions = [
80- Region ( kind = "function" , name = "execl" , start = 4 , end_main = 9 , end_total = 9 ),
81- Region ( kind = "function" , name = "execle" , start = 4 , end_main = 9 , end_total = 9 ),
82- Region ( kind = "function" , name = "execlp" , start = 4 , end_main = 9 , end_total = 9 ),
83- Region ( kind = "function" , name = "execlpe" , start = 4 , end_main = 9 , end_total = 9 ),
102+ region ( "function" , "execl" , start = 4 , end = 9 ),
103+ region ( "function" , "execle" , start = 4 , end = 9 ),
104+ region ( "function" , "execlp" , start = 4 , end = 9 ),
105+ region ( "function" , "execlpe" , start = 4 , end = 9 ),
84106 ],
85107 ),
86108 region_test_case (
87109 rst = "lzma.rst" ,
88110 regions = [
89- Region ("exception" , "LZMAError" , start = 26 , end_main = 29 , end_total = 29 ),
90- Region ("function" , "open" , start = 35 , end_main = 68 , end_total = 68 ),
91- Region ("method" , "LZMAFile.peek" , start = 108 , end_main = 117 , end_total = 117 ),
92- Region ("attribute" , "LZMAFile.mode" , start = 119 , end_main = 123 , end_total = 123 ),
93- Region ("attribute" , "LZMAFile.name" , start = 125 , end_main = 130 , end_total = 130 ),
94- Region ("class" , "LZMAFile" , start = 71 , end_main = 107 , end_total = 141 ),
95- Region ("method" , "LZMACompressor.compress" , start = 209 , end_main = 215 , end_total = 215 ),
96- Region ("method" , "LZMACompressor.flush" , start = 217 , end_main = 222 , end_total = 222 ),
97- Region ("class" , "LZMACompressor" , start = 147 , end_main = 208 , end_total = 222 ),
98- Region ("method" , "LZMADecompressor.decompress" , start = 254 , end_main = 279 , end_total = 279 ),
99- Region ("attribute" , "LZMADecompressor.check" , start = 281 , end_main = 285 , end_total = 285 ),
100- Region ("attribute" , "LZMADecompressor.eof" , start = 287 , end_main = 289 , end_total = 289 ),
101- Region ("attribute" , "LZMADecompressor.unused_data" , start = 291 , end_main = 295 , end_total = 295 ),
102- Region ("attribute" , "LZMADecompressor.needs_input" , start = 297 , end_main = 302 , end_total = 302 ),
103- Region ("class" , "LZMADecompressor" , start = 225 , end_main = 253 , end_total = 302 ),
104- Region ("function" , "compress" , start = 304 , end_main = 310 , end_total = 310 ),
105- Region ("function" , "decompress" , start = 313 , end_main = 322 , end_total = 322 ),
106- Region ("function" , "is_check_supported" , start = 328 , end_main = 335 , end_total = 335 ),
107- Region ("module" , "lzma" , start = 1 , end_main = 25 , end_total = 346 ),
111+ region ("exception" , "LZMAError" , start = 26 , end = 29 ),
112+ region ("function" , "open" , start = 35 , end = 68 ),
113+ region ("method" , "LZMAFile.peek" , start = 108 , end = 117 ),
114+ region ("attribute" , "LZMAFile.mode" , start = 119 , end = 123 ),
115+ region ("attribute" , "LZMAFile.name" , start = 125 , end = 130 ),
116+ region ("class" , "LZMAFile" , start = 71 , end_main = 107 , end_total = 141 ),
117+ region ("method" , "LZMACompressor.compress" , start = 209 , end = 215 ),
118+ region ("method" , "LZMACompressor.flush" , start = 217 , end = 222 ),
119+ region ("class" , "LZMACompressor" , start = 147 , end_main = 208 , end_total = 222 ),
120+ region ("method" , "LZMADecompressor.decompress" , start = 254 , end = 279 ),
121+ region ("attribute" , "LZMADecompressor.check" , start = 281 , end = 285 ),
122+ region ("attribute" , "LZMADecompressor.eof" , start = 287 , end = 289 ),
123+ region ("attribute" , "LZMADecompressor.unused_data" , start = 291 , end = 295 ),
124+ region ("attribute" , "LZMADecompressor.needs_input" , start = 297 , end = 302 ),
125+ region ("class" , "LZMADecompressor" , start = 225 , end_main = 253 , end_total = 302 ),
126+ region ("function" , "compress" , start = 304 , end = 310 ),
127+ region ("function" , "decompress" , start = 313 , end = 322 ),
128+ region ("function" , "is_check_supported" , start = 328 , end = 335 ),
129+ region ("module" , "lzma" , start = 1 , end_main = 25 , end_total = 346 ),
108130 ],
109131 ),
110132]
0 commit comments