Xamarin Public Jenkins (auto-signing) 468663ddbb Imported Upstream version 6.10.0.49
Former-commit-id: 1d6753294b2993e1fbf92de9366bb9544db4189b
2020-01-16 16:38:04 +00:00

31 lines
964 B
Python

# -*- coding: utf-8 -*-
# The LLVM Compiler Infrastructure
#
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
import libear as sut
import unittest
import os.path
class TemporaryDirectoryTest(unittest.TestCase):
def test_creates_directory(self):
dirname = None
with sut.TemporaryDirectory() as tmpdir:
self.assertTrue(os.path.isdir(tmpdir))
dirname = tmpdir
self.assertIsNotNone(dirname)
self.assertFalse(os.path.exists(dirname))
def test_removes_directory_when_exception(self):
dirname = None
try:
with sut.TemporaryDirectory() as tmpdir:
self.assertTrue(os.path.isdir(tmpdir))
dirname = tmpdir
raise RuntimeError('message')
except:
self.assertIsNotNone(dirname)
self.assertFalse(os.path.exists(dirname))