Debian Codegraph @

benchmarks/conftest.py

raw
1
2 from pathlib import (
3 Path)
4
5 import pytest
6
7 from pathspec.util import (
8 iter_tree_files)
9
10
11 @pytest.fixture(scope='session')
12 def cpython_dir() -> Path:
13 return Path("~/Downloads/cpython").expanduser()
14
15
16 @pytest.fixture(scope='session')
17 def cpython_files(cpython_dir: Path) -> set[str]:
18 return set(iter_tree_files(cpython_dir))
19
20
21 @pytest.fixture(scope='session')
22 def cpython_gi_file(cpython_dir: Path) -> Path:
23 return cpython_dir / ".gitignore"
24
25
26 @pytest.fixture(scope='session')
27 def cpython_gi_lines_all(cpython_gi_file: Path) -> list[str]:
28 return [
29 __line for __line in cpython_gi_file.read_text().splitlines()
30 if __line and not __line.startswith('#')
31 ]
32
33
34 @pytest.fixture(scope='session')
35 def cpython_gi_lines_1(cpython_gi_lines_all: list[str]) -> list[str]:
36 return [
37 "*.cover",
38 ]
39
40
41 @pytest.fixture(scope='session')
42 def cpython_gi_lines_5(cpython_gi_lines_all: list[str]) -> list[str]:
43 return [
44 "*.cover",
45 "*.iml",
46 "Modules/config.c",
47 "CLAUDE.local.md",
48 "Doc/data/python*.abi",
49 ]
50
51
52 @pytest.fixture(scope='session')
53 def cpython_gi_lines_15(cpython_gi_lines_all: list[str]) -> list[str]:
54 return (
55 cpython_gi_lines_all[:5]
56 + cpython_gi_lines_all[82:87]
57 + cpython_gi_lines_all[-5:]
58 )
59
60
61 @pytest.fixture(scope='session')
62 def cpython_gi_lines_25(cpython_gi_lines_all: list[str]) -> list[str]:
63 return (
64 cpython_gi_lines_all[:10]
65 + cpython_gi_lines_all[82:87]
66 + cpython_gi_lines_all[-10:]
67 )
68
69
70 @pytest.fixture(scope='session')
71 def cpython_gi_lines_50(cpython_gi_lines_all: list[str]) -> list[str]:
72 return (
73 cpython_gi_lines_all[:20]
74 + cpython_gi_lines_all[80:90]
75 + cpython_gi_lines_all[-20:]
76 )
77
78
79 @pytest.fixture(scope='session')
80 def cpython_gi_lines_100(cpython_gi_lines_all: list[str]) -> list[str]:
81 return (
82 cpython_gi_lines_all[:40]
83 + cpython_gi_lines_all[80:100]
84 + cpython_gi_lines_all[-40:]
85 )
86
87
88 @pytest.fixture(scope='session')
89 def cpython_file_match_end() -> str:
90 """
91 File matching pattern near the end of cpython ".gitignore".
92 """
93 return "CLAUDE.local.md"
94
95
96 @pytest.fixture(scope='session')
97 def cpython_file_match_middle() -> str:
98 """
99 File matching pattern near the middle of cpython ".gitignore".
100 """
101 return "Modules/config.c"
102
103
104 @pytest.fixture(scope='session')
105 def cpython_file_match_none() -> str:
106 """
107 File not matching any pattern in cpython ".gitignore".
108 """
109 return "Unladen Swallow"
110
111
112 @pytest.fixture(scope='session')
113 def cpython_file_match_start() -> str:
114 """
115 File matching pattern near the beginning of cpython ".gitignore".
116 """
117 return "spam.cover"
118
119
120 @pytest.fixture(scope='session')
121 def flit_dir() -> Path:
122 return Path("~/Downloads/flit").expanduser()
123
124
125 @pytest.fixture(scope='session')
126 def flit_files(flit_dir: Path) -> set[str]:
127 return set(iter_tree_files(flit_dir))
128
129
130 @pytest.fixture(scope='session')
131 def flit_gi_file(flit_dir: Path) -> Path:
132 return flit_dir / ".gitignore"
133
134
135 @pytest.fixture(scope='session')
136 def flit_gi_lines_all(flit_gi_file: Path) -> list[str]:
137 return flit_gi_file.read_text().splitlines()
138
139
140 @pytest.fixture(scope='session')
141 def flit_gi_lines_1() -> list[str]:
142 return [
143 "/dist/",
144 ]
145
146
147 @pytest.fixture(scope='session')
148 def flit_gi_lines_2() -> list[str]:
149 return [
150 "/dist/",
151 "*.pyc",
152 ]
153
154 @pytest.fixture(scope='session')
155 def flit_gi_lines_5() -> list[str]:
156 return [
157 "/dist/",
158 "__pycache__/",
159 "/htmlcov/",
160 "*.pyc",
161 ".python-version",
162 ]
163
164
165 @pytest.fixture(scope='session')
166 def flit_file_match_end() -> str:
167 """
168 File matching pattern near the end of flit ".gitignore".
169 """
170 return "green.pyc"
171
172
173 @pytest.fixture(scope='session')
174 def flit_file_match_middle() -> str:
175 """
176 File matching pattern near the middle of flit ".gitignore".
177 """
178 return "htmlcov/eggs"
179
180
181 @pytest.fixture(scope='session')
182 def flit_file_match_none() -> str:
183 """
184 File not matching any pattern in flit ".gitignore".
185 """
186 return "Unladen Swallow"
187
188
189 @pytest.fixture(scope='session')
190 def flit_file_match_start() -> str:
191 """
192 File matching pattern near the beginning of flit ".gitignore".
193 """
194 return "dist/ham"