forked from jefersondaniel/pydantic-mongo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphulpyfile.py
37 lines (29 loc) · 982 Bytes
/
phulpyfile.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
import xml.etree.ElementTree as ET
from os import system, unlink
from os.path import dirname, join
from phulpy import task
@task
def test(phulpy):
phulpy.start(['lint', 'typecheck', 'unit_test'])
@task
def lint(phulpy):
result = system('flake8 pydantic_mongo')
if result:
raise Exception('lint test failed')
@task
def unit_test(phulpy):
result = system(
'pytest --cov-report term-missing'
+ ' --cov-report xml --cov=pydantic_mongo test'
)
if result:
raise Exception('Unit tests failed')
coverage_path = join(dirname(__file__), 'coverage.xml')
xml = ET.parse(coverage_path).getroot()
if float(xml.get('line-rate')) < 1:
raise Exception('Unit test is not fully covered')
@task
def typecheck(phulpy):
result = system(r'find ./pydantic_mongo -name "*.py" -exec mypy --ignore-missing-imports --follow-imports=skip --strict-optional {} \+')
if result:
raise Exception('lint test failed')