示例#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())
 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())
示例#3
0
文件: user.py 项目: 2m/pysteam
 def save_shortcuts(self, path=None, makedirs=True):
     if path is None:
         path = self.shortcuts_file()
     parent_directory = os.path.dirname(path)
     if not os.path.isdir(parent_directory) and makedirs:
         try:
             os.makedirs(parent_directory)
         except OSError:
             raise OSError("Cannot write to directory `%s`." %
                           parent_directory)
     # Write shortcuts to file
     try:
         contents = ShortcutGenerator().to_string(self.shortcuts)
         with open(path, "w") as f:
             f.write(contents)
     except IOError:
         raise IOError("Cannot save file to `%s`. Permission Denied")
示例#4
0
 def test_file_equality(self):
     file_contents = open(path,"r").read()
     shortcuts = ShortcutParser().parse(path)
     generated_contents = ShortcutGenerator().to_string(shortcuts)
     self.assertEqual(file_contents.lower(),generated_contents.lower())