-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsetup.py
More file actions
executable file
·47 lines (37 loc) · 1.29 KB
/
Copy pathsetup.py
File metadata and controls
executable file
·47 lines (37 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env python3
from __future__ import annotations
import subprocess
import sys
import os
from pathlib import Path
from setuptools import Command, setup
class RunTests(Command):
"""Compatibility test command for `python setup.py test`."""
description = "run project tests with unittest discovery"
user_options: list[tuple[str, str | None, str]] = []
def initialize_options(self) -> None: # pragma: no cover - setuptools API
return None
def finalize_options(self) -> None: # pragma: no cover - setuptools API
return None
def run(self) -> None:
root = Path(__file__).resolve().parent
src_dir = root / "src"
env = os.environ.copy()
pythonpath_entries = [str(src_dir)]
existing_pythonpath = env.get("PYTHONPATH", "")
for raw_entry in existing_pythonpath.split(os.pathsep):
if raw_entry:
pythonpath_entries.append(raw_entry)
env["PYTHONPATH"] = os.pathsep.join(pythonpath_entries)
cmd = [
sys.executable,
"-m",
"unittest",
"discover",
"-s",
"tests",
"-p",
"test*.py",
]
raise SystemExit(subprocess.call(cmd, cwd=root, env=env))
setup(cmdclass={"test": RunTests})