add codingstyle and json linting tests
Hanno Böck

Hanno Böck commited on 2019-12-12 18:29:13
Zeige 3 geänderte Dateien mit 41 Einfügungen und 0 Löschungen.

... ...
@@ -0,0 +1,26 @@
1
+import unittest
2
+import glob
3
+import json
4
+import sys
5
+import difflib
6
+
7
+
8
+class TestJsonLint(unittest.TestCase):
9
+    def test_json_lint(self):
10
+        valid = True
11
+        for f in glob.glob("freewvsdb/*.json"):
12
+            fp = open(f, "r")
13
+            orig = fp.read()
14
+            fp.close()
15
+            tmp = json.loads(orig)
16
+            new = json.dumps(tmp, indent=2)
17
+            if (orig != new):
18
+                print("json %s not valid" % f)
19
+                sys.stdout.writelines(difflib.unified_diff(orig, new))
20
+                valid = False
21
+        if not valid:
22
+            raise Exception("Unlinted json files found")
23
+
24
+
25
+if __name__ == '__main__':
26
+    unittest.main()
... ...
@@ -0,0 +1,15 @@
1
+import unittest
2
+import subprocess
3
+import glob
4
+
5
+
6
+class TestCodingstyle(unittest.TestCase):
7
+    def test_codingstyle(self):
8
+        subprocess.run(["pycodestyle", "--ignore=W503", "freewvs"]
9
+                       + glob.glob("tests/*.py"), check=True)
10
+        subprocess.run(["pyflakes", "freewvs"]
11
+                       + glob.glob("tests/*.py"), check=True)
12
+
13
+
14
+if __name__ == '__main__':
15
+    unittest.main()
0 16