-
Notifications
You must be signed in to change notification settings - Fork 1
/
tasks.py
64 lines (44 loc) · 1.25 KB
/
tasks.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
from invoke import task
import platform
import os
from shutil import rmtree
from letra import __version__
def black(c, check):
cmd = f"black . --line-length=79 {'--check' if check is True else ''}"
return c.run(cmd)
@task(aliases=["f"])
def format(c):
return black(c, False)
@task(aliases=["cf", "fc"])
def check_format(c):
return black(c, True)
@task()
def clean_test_reports(c):
rmtree(".test-reports/", ignore_errors=True)
if os.path.exists(".coverage"):
os.remove(".coverage")
@task(aliases=["cl"], pre=[clean_test_reports])
def clean(c):
pass
@task(aliases=["t"], pre=[clean])
def test(c):
return c.run("pytest")
@task(aliases=["roc"])
def reopen_coverage(c):
path = ".test-reports/coverage/unit/html/index.html"
operating_system = platform.system()
if operating_system == "Linux":
return c.run("xdg-open " + path)
elif operating_system == "Windows":
return c.run("cmd.exe /C start " + path)
else:
return c.run("open " + path)
@task(aliases=["oc", "c"], pre=[test], post=[reopen_coverage])
def open_coverage(c):
pass
@task(aliases=["l", "lp"])
def lint(c):
return c.run("pycodestyle .")
@task(aliases=["pv", "sv"])
def print_version(c):
return print(__version__)