[tidy] check for duplicate keys in .json files

This commit is contained in:
Owen Coutts 2016-07-06 19:15:56 +02:00
parent 9b2b101d19
commit ff4cb7f80a
3 changed files with 25 additions and 1 deletions

View file

@ -0,0 +1,7 @@
{
"key": "value",
"other_key": {
"the_duplicated_key": 1,
"the_duplicated_key": 2
}
}

View file

@ -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"