Esempio n. 1
0
 def test_delete(self):
     File.copy('testResources\\FileTest.txt',
               "testResources\\FileTestTemp.txt")
     self.assertTrue(File.exists("testResources\\FileTestTemp.txt"))
     File.delete("testResources\\FileTestTemp.txt")
     self.assertFalse(File.exists("testResources\\FileTestTemp.txt"))
     pass
Esempio n. 2
0
 def test_writetext(self):
     File.write_text('testResources\\FileTest.txt', "Nothing")
     self.assertEqual(File.read_text('testResources\\FileTest.txt'),
                      "Nothing")
     File.write_text('testResources\\FileTest.txt',
                     'Contents Of File\nSecond Line Of Content')
     self.assertEqual(File.read_text('testResources\\FileTest.txt'),
                      'Contents Of File\nSecond Line Of Content')
     pass
Esempio n. 3
0
 def test_readtext(self):
     self.assertEqual(File.read_text('testResources\\FileTest.txt'),
                      'Contents Of File\nSecond Line Of Content')
Esempio n. 4
0
 def test_exists(self):
     self.assertTrue(File.exists(r'testResources\FileTest.txt'))
     self.assertFalse(File.exists(r'testResources\FILEDOESNOTEXIST.txt'))
Esempio n. 5
0
 def test_readlines(self):
     self.assertEqual(File.read_lines('testResources\\FileTest.txt'),
                      ['Contents Of File\n', 'Second Line Of Content'])
Esempio n. 6
0
 def replace_file(path, pattern, replacement):
     text = File.read_text(path)
     text = Regex.replace_string(text, pattern, replacement)
     File.write_text(path, text)
Esempio n. 7
0
 def match_file(path, pattern):
     text = File.read_text(path)
     return Regex.match_string(text, pattern)
Esempio n. 8
0
 def get_resource_path(resource):
     # TODO: write unit test
     if File.exists(Path.combine(Path.get_file_path(__file__), resource)):
         return Path.combine(Path.get_file_path(__file__), resource)
     else:
         raise Exception('The given resource could not be found')