-
Notifications
You must be signed in to change notification settings - Fork 39
/
test_pmp_flake8.py
38 lines (35 loc) · 1.21 KB
/
test_pmp_flake8.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
from __future__ import print_function
import unittest
import os
import subprocess
import shlex
class TestFlake8(unittest.TestCase):
def testFlake8(self):
pth = os.path.dirname(__file__)
pth = os.path.join(pth, "..")
pth = os.path.abspath(pth)
pth = os.path.join(pth, "pcmdi_metrics")
nopth = os.path.join(pth, "devel")
print()
print()
print()
print()
print("---------------------------------------------------")
print("RUNNING: flake8 on directory %s" % pth)
print("---------------------------------------------------")
print()
print()
print()
print()
cmd = "flake8 --show-source --statistics " +\
"--ignore=F999,F405,E121,E123,E126,E226,E24,E704,W605,W504 " +\
"--max-line-length=120 %s --exclude %s" % (pth,nopth)
P = subprocess.Popen(shlex.split(cmd),
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
out,e = P.communicate()
out = out.decode("utf-8")
if out != "":
print(out)
self.assertEqual(out, "")