def test_already_exists_rollback_dir(self):
        # Test the rollback feature by attempting to create a dir and a file,
        # the second of which already exists.
        # Test that the dir gets deleted on the rollback.
        tempdir = tempfile.mkdtemp()
        try:
            dir_one = os.path.join(tempdir, 'dir_one')
            file_two = os.path.join(tempdir, 'two.txt')
            # Create the file_two to cause the error
            open(file_two, 'w').close()

            afc = util.AtomicFileCreator()
            afc.create_file('dir', dir_one, None)
            try:
                afc.create_file('file', file_two, 'def')
            except __HOLE__:
                assert os.path.exists(dir_one)
                assert os.path.isdir(dir_one)
                afc._rollback()
                # Make sure rollback deletes it
                assert not os.path.exists(dir_one)
                # file_two was created before, and it should still exist
                assert os.path.exists(file_two)
            else:
                # No IOError, fail the test
                assert False, "Expected IOError not raised"
        finally:
            shutil.rmtree(tempdir)
dataset/ETHPy150Open zerovm/zerovm-cli/zpmlib/tests/test_util.py/TestAtomicFileCreator.test_already_exists_rollback_dir