aboutsummaryrefslogtreecommitdiffstats
path: root/python/tidy/servo_tidy_tests
diff options
context:
space:
mode:
authorOwen Coutts <owen@owencoutts.com>2016-07-06 19:15:56 +0200
committerOwen Coutts <owen@owencoutts.com>2016-07-08 11:12:12 +0200
commitff4cb7f80a0560e0d4d72e44de71d39fada1d171 (patch)
tree68df39738bdf039f6052b9c825ea5e7d27fffe91 /python/tidy/servo_tidy_tests
parent9b2b101d195e2aa042ea71dae0ec6e50eb6d11d9 (diff)
downloadservo-ff4cb7f80a0560e0d4d72e44de71d39fada1d171.tar.gz
servo-ff4cb7f80a0560e0d4d72e44de71d39fada1d171.zip
[tidy] check for duplicate keys in .json files
Diffstat (limited to 'python/tidy/servo_tidy_tests')
-rw-r--r--python/tidy/servo_tidy_tests/duplicate_key.json7
-rw-r--r--python/tidy/servo_tidy_tests/test_tidy.py5
2 files changed, 12 insertions, 0 deletions
diff --git a/python/tidy/servo_tidy_tests/duplicate_key.json b/python/tidy/servo_tidy_tests/duplicate_key.json
new file mode 100644
index 00000000000..6998c789ac9
--- /dev/null
+++ b/python/tidy/servo_tidy_tests/duplicate_key.json
@@ -0,0 +1,7 @@
+{
+ "key": "value",
+ "other_key": {
+ "the_duplicated_key": 1,
+ "the_duplicated_key": 2
+ }
+}
diff --git a/python/tidy/servo_tidy_tests/test_tidy.py b/python/tidy/servo_tidy_tests/test_tidy.py
index 096fb5676b2..8db19a5efd7 100644
--- a/python/tidy/servo_tidy_tests/test_tidy.py
+++ b/python/tidy/servo_tidy_tests/test_tidy.py
@@ -109,6 +109,11 @@ class CheckTidiness(unittest.TestCase):
self.assertEqual('Invalid control character at: line 3 column 40 (char 61)', errors.next()[2])
self.assertNoMoreErrors(errors)
+ def test_json_with_duplicate_key(self):
+ errors = tidy.collect_errors_for_files(iterFile('duplicate_key.json'), [tidy.check_json], [], print_text=False)
+ self.assertEqual('Duplicated Key (the_duplicated_key)', errors.next()[2])
+ self.assertNoMoreErrors(errors)
+
def test_lock(self):
errors = tidy.collect_errors_for_files(iterFile('duplicated_package.lock'), [tidy.check_lock], [], print_text=False)
msg = """duplicate versions for package "test"