Skip to content

Commit be1d1d8

Browse files
committed
Test all json files in source
1 parent 2938009 commit be1d1d8

3 files changed

Lines changed: 28 additions & 17 deletions

File tree

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ install:
88
- "pip install -r ./travis/requirements.txt"
99

1010
script:
11-
- "python ./travis/travis_config.py"
11+
- "python ./travis/test_json.py"
1212
- "py.test . -v --cov . --cov-report term-missing"
1313

1414
after_success:

travis/test_json.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
"""
2+
Travis Test file:
3+
Test JSON files for errors.
4+
"""
5+
6+
import json
7+
import fnmatch
8+
import codecs
9+
import os
10+
import sys
11+
12+
error = False
13+
print("Travis: Testing all JSON files in source")
14+
15+
for root, dirs, files in os.walk('.'):
16+
for filename in fnmatch.filter(files, '*.json'):
17+
file = os.path.join(root, filename)
18+
try:
19+
with codecs.open(file, encoding="utf-8") as f:
20+
json.load(f)
21+
print("Travis: {} is a valid JSON file".format(file))
22+
except Exception as e:
23+
error = True
24+
print("Travis: {} is not a valid JSON file, json.load threw exception:\n{}".format(file, e))
25+
26+
if error:
27+
sys.exit(1)

travis/travis_config.py

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)