0aeada3c9a197050c08a3292ec98a5db4b05e831
Hanno Böck add codingstyle and json li...

Hanno Böck authored 4 years ago

1) import unittest
2) import glob
3) import json
4) import sys
5) import difflib
6) 
7) 
8) class TestJsonLint(unittest.TestCase):
Hanno Böck disable jsonlint test on py...

Hanno Böck authored 4 years ago

9) 
10)     @unittest.skipIf(sys.version_info < (3, 6, 0),
11)                      "json.dumps force-sorts on python 3.5")
Hanno Böck add codingstyle and json li...

Hanno Böck authored 4 years ago

12)     def test_json_lint(self):
13)         valid = True
14)         for f in glob.glob("freewvsdb/*.json"):
15)             fp = open(f, "r")
16)             orig = fp.read()
17)             fp.close()
18)             tmp = json.loads(orig)
19)             new = json.dumps(tmp, indent=2)
Hanno Böck avoid some pylint warnings

Hanno Böck authored 4 years ago

20)             if orig != new:
Hanno Böck add codingstyle and json li...

Hanno Böck authored 4 years ago

21)                 print("json %s not valid" % f)
22)                 sys.stdout.writelines(difflib.unified_diff(orig, new))
23)                 valid = False
Hanno Böck avoid some pylint warnings

Hanno Böck authored 4 years ago

24)         self.assertTrue(valid)