Debian Codegraph @

tests/tox_env/python/virtual_env/package/conftest.py

raw
1 from __future__ import annotations
2
3 import sys
4 from textwrap import dedent
5 from typing import TYPE_CHECKING
6
7 import pytest
8
9 if TYPE_CHECKING:
10 from collections.abc import Callable
11 from pathlib import Path
12
13
14 @pytest.fixture(scope="session")
15 def pkg_with_extras_project(tmp_path_factory: pytest.TempPathFactory) -> Path:
16 py_ver = ".".join(str(i) for i in sys.version_info[0:2])
17 setup_cfg = f"""
18 [metadata]
19 name = demo
20 version = 1.0.0
21 [options]
22 packages = find:
23 install_requires =
24 platformdirs>=4.3.8
25 colorama>=0.4.6
26
27 [options.extras_require]
28 testing =
29 covdefaults>=1.2; python_version == '2.7' or python_version == '{py_ver}'
30 pytest>=5.4.1; python_version == '{py_ver}'
31 docs =
32 sphinx>=3
33 sphinx-rtd-theme>=0.4.3,<1
34 format =
35 black>=3
36 flake8
37 """
38 tmp_path = tmp_path_factory.mktemp("prj")
39 (tmp_path / "setup.cfg").write_text(dedent(setup_cfg))
40 (tmp_path / "README").write_text("")
41 (tmp_path / "setup.py").write_text("from setuptools import setup; setup()")
42 toml = '[build-system]\nrequires=["setuptools"]\nbuild-backend = "setuptools.build_meta"'
43 (tmp_path / "pyproject.toml").write_text(toml)
44 return tmp_path
45
46
47 @pytest.fixture(scope="session")
48 def pkg_with_pdm_backend(
49 tmp_path_factory: pytest.TempPathFactory,
50 pkg_builder: Callable[[Path, Path, list[str], bool], Path],
51 ) -> Path:
52 tmp_path = tmp_path_factory.mktemp("skeleton")
53
54 pyproject_toml = """
55 [build-system]
56 requires = ["pdm-backend"]
57 build-backend = "pdm.backend"
58
59 [project]
60 name = "skeleton"
61 description = "Just a skeleton for reproducing #3512."
62 version = "0.1.1337"
63 dependencies = [
64 "requests",
65 ]
66
67 [tool.pdm.build]
68 includes = [
69 "skeleton/",
70 ]
71 source-includes = [
72 "tox.ini",
73 ]
74 """
75 (tmp_path / "pyproject.toml").write_text(dedent(pyproject_toml))
76 (tmp_path / "skeleton").mkdir(exist_ok=True)
77 (tmp_path / "skeleton" / "__init__.py").touch()
78
79 dist = tmp_path / "dist"
80 pkg_builder(dist, tmp_path, ["sdist"], False)
81
82 return tmp_path