-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_style.py
42 lines (27 loc) · 1.11 KB
/
test_style.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
import os
import subprocess
import re
def test_flake8():
proc = subprocess.Popen("flake8", stdout=subprocess.PIPE)
proc.wait()
out = proc.stdout.read().decode()
lines = [l.strip() for l in out.split("\n")if l]
print(out)
assert not bool(lines)
def test_pylint():
proc = subprocess.Popen(("pylint --disable=missing-docstring,"
"too-many-branches,no-name-in-module,"
"attribute-defined-outside-init,"
"too-many-instance-attributes"
"too-few-public-methods,"
"too-many-locals,too-many-arguments,"
"too-many-statements,no-member,unused-argument,"
" .").split(),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
proc.wait()
out = proc.stdout.read().decode()
print(out)
last_line = [l for l in out.split("\n")if l][-1]
m = re.match(r"Your code has been rated at 10\.00\/10", last_line.strip())
assert m is not None