Exemple #1
0
 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())
Exemple #2
0
 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
Exemple #3
0
 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)
Exemple #4
0
 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), [])
Exemple #5
0
 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)
 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), [])