def test_json_output_from_single_file(self): for test_file in _TEST_SINGLE_FILES: # Get old JSON example test output expected_json = _slurp_file(_TEST_ROOT, test_file + '.json') # Generate new output to check output = extract_strings.extract_file( os.path.join(_EXERCISE_ROOT, test_file + '.html')) output = json.dumps(output, cls=extract_strings._SetEncoder) self.assertEqual(output, expected_json, test_file)
def test_json_output_from_single_file(self): for test_file in _TEST_SINGLE_FILES: expected_output = _load_test_json(test_file) # The python routines store the matching filenames as a # set. json stores them as a list (it doesn't have sets). # We don't care about order, so we convert from the list # to the set for this test. for k in expected_output: expected_output[k] = set( (str(file), linenum) for (file, linenum) in expected_output[k]) # Generate new output to check output = extract_strings.extract_file( os.path.join(_TEST_ROOT, test_file + '.html'), {}) self.assertEqual(output, expected_output)