예제 #1
0
    def test_delete_file(self):
        """ Tests the method that deletes a file."""

        self.assertTrue(Common.delete_file(''))
        self.assertTrue(Common.delete_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'))
예제 #2
0
    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'))