def test_create_file(self): """ Tests the method that creates a file.""" self.assertFalse(Common.create_file('')) self.assertFalse(Common.create_file(None)) # Create the file self.assertTrue(Common.create_file(self.test_data_root + 'Z.txt')) # Delete the file self.assertTrue(Common.delete_file(self.test_data_root + 'Z.txt')) # Now check file was deleted self.assertFalse(Common.file_exists(self.test_data_root + 'Z.txt'))
def test_append_to_file(self): """ Tests the methods that appends text to a file.""" # Create the file self.assertTrue(Common.create_file(self.test_data_root + 'Z.txt')) Common.append_to_file(self.test_data_root + 'Z.txt', '1,2,3,4,5') # Now check contents are as expected self.assertEqual(Common.read_file_as_string(self.test_data_root + 'Z.txt'), '1,2,3,4,5') # Delete the file self.assertTrue(Common.delete_file(self.test_data_root + 'Z.txt')) # Now check file was deleted self.assertFalse(Common.file_exists(self.test_data_root + 'Z.txt'))