- Notifications
You must be signed in to change notification settings - Fork 417
/
Copy pathtest__sourcecode.py
40 lines (32 loc) · 1.19 KB
/
test__sourcecode.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
# Copyright (C) 2016-present the asyncpg authors and contributors
# <see AUTHORS file>
#
# This module is part of asyncpg and is released under
# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
importos
importsubprocess
importsys
importunittest
deffind_root():
returnos.path.dirname(os.path.dirname(os.path.abspath(__file__)))
classTestFlake8(unittest.TestCase):
deftest_flake8(self):
try:
importflake8# NoQA
exceptImportError:
raiseunittest.SkipTest('flake8 module is missing')
root_path=find_root()
config_path=os.path.join(root_path, '.flake8')
ifnotos.path.exists(config_path):
raiseRuntimeError('could not locate .flake8 file')
try:
subprocess.run(
[sys.executable, '-m', 'flake8', '--config', config_path],
check=True,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
cwd=root_path)
exceptsubprocess.CalledProcessErrorasex:
output=ex.output.decode()
raiseAssertionError(
'flake8 validation failed:\n{}'.format(output)) fromNone