-
Notifications
You must be signed in to change notification settings - Fork 26
/
setup.py
74 lines (58 loc) · 1.75 KB
/
setup.py
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import subprocess
from glob import glob
from setuptools import Command, setup
class LintCMD(Command):
user_options = [
(
"check=",
"c",
"if True check if files pass linting checks; don't actually lint",
)
]
def initialize_options(self):
self.check = False
def finalize_options(self):
self.check = self.check == "True"
def run(self):
command = ["black", "harvest"]
if self.check:
command.extend(["--check", "-v", "--diff"])
exit(subprocess.run(command).returncode)
class CoverageTestCMD(Command):
user_options = [("live=", "l", "a list of files in the livetest folder to run")]
def initialize_options(self):
self.live = ""
def finalize_options(self):
self.live = [
"tests/livetest/test_api_" + test + ".py"
for test in self.live.split(",")
if test
]
def run(self):
exit_code = subprocess.run(
[
"coverage",
"run",
"-p",
"-m",
"unittest",
"discover",
"-s",
"tests/unittest",
]
).returncode
for test in self.live:
exit_code += subprocess.run(["coverage", "run", "-p", test]).returncode
exit_code += subprocess.run(
["coverage", "combine"] + glob(".coverage.*")
).returncode
exit_code += subprocess.run(["coverage", "report"]).returncode
exit_code += subprocess.run(["coverage", "html"]).returncode
exit(exit_code)
setup(
cmdclass={
"lint": LintCMD,
"test": CoverageTestCMD,
},
include_package_data=True,
)