forked from devoxin/Lavalink.py
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_tests.py
45 lines (34 loc) · 1.44 KB
/
run_tests.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
import sys
from io import StringIO
import pylint.lint as pylint
from flake8.api import legacy
from pylint.reporters import text
def test_flake8():
style_guide = legacy.get_style_guide()
report = style_guide.check_files(['lavalink'])
statistics = report.get_statistics('E')
failed = bool(statistics)
if not failed:
print('OK')
def test_pylint():
stdout = StringIO()
reporter = text.TextReporter(stdout)
opts = ['--max-line-length=150', '--score=no', '--disable=missing-docstring, wildcard-import, '
'attribute-defined-outside-init, too-few-public-methods, '
'old-style-class,import-error,invalid-name,no-init,'
'too-many-instance-attributes,protected-access,too-many-arguments,'
'too-many-public-methods,logging-format-interpolation,'
'too-many-branches', 'lavalink']
pylint.Run(opts, reporter=reporter, do_exit=False)
out = reporter.out.getvalue()
failed = bool(out)
msg = 'OK' if not failed else out
print(msg)
return failed
if __name__ == '__main__':
print('-- flake8 test --')
flake_failed = test_flake8()
print('-- pylint test --')
pylint_failed = test_pylint()
if flake_failed or pylint_failed:
sys.exit(1)