def test_vdf_parsing(self, file): """Tests that parsing and regenerating a vdf file generates the same contents""" path = os.path.join(vdfs_folder, file) file_contents = open(path, "r").read() shortcuts = ShortcutParser().parse(path) generated_contents = ShortcutGenerator().to_string(shortcuts) self.assertEqual(file_contents.lower(), generated_contents.lower())
def _load_shortcuts(self): try: parsed_shortcuts = ShortcutParser().parse(self.shortcuts_file()) except IOError: parsed_shortcuts = [] if parsed_shortcuts == None: # TODO: Raise a decent error print("Parsing error on file: %s" % file) parsed_shortcuts = [] return parsed_shortcuts
def test_raises_io_error_when_file_doesnt_exist_and_require_exists_is_false( self): invalid_path = os.path.join("this", "path", "doesnt", "exist") parser = ShortcutParser() with self.assertRaises(IOError): parser.parse(invalid_path, require_exists=True)
def test_returns_empty_list_when_file_doesnt_exist(self): invalid_path = os.path.join("this", "path", "doesnt", "exist") parser = ShortcutParser() self.assertEqual(parser.parse(invalid_path), [])
def test_raises_io_error_when_file_doesnt_exist(self): invalid_path = os.path.join("this", "path", "doesnt", "exist") parser = ShortcutParser() with self.assertRaises(IOError): parser.parse(invalid_path)