Debian Codegraph @

tests/conftest.py

raw symbols SCIP
1 import textwrap
2 import zipfile
3
4 import pytest
5
6
7 @pytest.fixture
8 def fancy_wheel(tmp_path):
9 return mock_wheel(tmp_path, "fancy")
10
11
12 @pytest.fixture
13 def another_fancy_wheel(tmp_path):
14 return mock_wheel(tmp_path, "another_fancy")
15
16
17 def mock_wheel(tmp_path, name):
18 path = tmp_path / f"{name}-1.0.0-py2.py3-none-any.whl"
19 files = {
20 f"{name}/": b"""""",
21 f"{name}/__init__.py": b"""\
22 def main():
23 print("I'm fancy.")
24 """,
25 f"{name}/__main__.py": b"""\
26 if __name__ == "__main__":
27 from . import main
28 main()
29 """,
30 f"{name}-1.0.0.data/data/{name}/": b"""""",
31 f"{name}-1.0.0.data/data/{name}/data.py": b"""\
32 # put me in data
33 """,
34 f"{name}-1.0.0.dist-info/": b"""""",
35 f"{name}-1.0.0.dist-info/top_level.txt": f"""\
36 {name}
37 """.encode(),
38 f"{name}-1.0.0.dist-info/entry_points.txt": f"""\
39 [console_scripts]
40 {name} = {name}:main
41
42 [gui_scripts]
43 {name}-gui = {name}:main
44 """.encode(),
45 f"{name}-1.0.0.dist-info/WHEEL": b"""\
46 Wheel-Version: 1.0
47 Generator: magic (1.0.0)
48 Root-Is-Purelib: true
49 Tag: py3-none-any
50 """,
51 f"{name}-1.0.0.dist-info/METADATA": f"""\
52 Metadata-Version: 2.1
53 Name: {name}
54 Version: 1.0.0
55 Summary: A fancy package
56 Author: Agendaless Consulting
57 Author-email: [email protected]
58 License: MIT
59 Keywords: fancy amazing
60 Platform: UNKNOWN
61 Classifier: Intended Audience :: Developers
62 """.encode(),
63 f"{name}-1.0.0.dist-info/RECORD": f"""\
64 {name}/__init__.py,sha256=qZ2qq7xVBAiUFQVv-QBHhdtCUF5p1NsWwSOiD7qdHN0,36
65 {name}/__main__.py,sha256=Wd4SyWJOIMsHf_5-0oN6aNFwen8ehJnRo-erk2_K-eY,61
66 {name}-1.0.0.data/data/{name}/data.py,sha256=nuFRUNQF5vP7FWE-v5ysyrrfpIaAvfzSiGOgfPpLOeI,17
67 {name}-1.0.0.dist-info/top_level.txt,sha256=SW-yrrF_c8KlserorMw54inhLjZ3_YIuLz7fYT4f8ao,6
68 {name}-1.0.0.dist-info/entry_points.txt,sha256=AxJl21_zgoNWjCfvSkC9u_rWSzGyCtCzhl84n979jCc,75
69 {name}-1.0.0.dist-info/WHEEL,sha256=1DrXMF1THfnBjsdS5sZn-e7BKcmUn7jnMbShGeZomgc,84
70 {name}-1.0.0.dist-info/METADATA,sha256=hRhZavK_Y6WqKurFFAABDnoVMjZFBH0NJRjwLOutnJI,236
71 {name}-1.0.0.dist-info/RECORD,,
72 """.encode(),
73 }
74
75 with zipfile.ZipFile(path, "w") as archive:
76 for name, indented_content in files.items():
77 archive.writestr(
78 name,
79 textwrap.dedent(indented_content.decode("utf-8")).encode("utf-8"),
80 )
81
82 return path