1 # -*- coding: utf-8 -*-
2 # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
3 # See https://llvm.org/LICENSE.txt for license information.
4 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
11 class TemporaryDirectoryTest(unittest
.TestCase
):
12 def test_creates_directory(self
):
14 with sut
.TemporaryDirectory() as tmpdir
:
15 self
.assertTrue(os
.path
.isdir(tmpdir
))
17 self
.assertIsNotNone(dirname
)
18 self
.assertFalse(os
.path
.exists(dirname
))
20 def test_removes_directory_when_exception(self
):
23 with sut
.TemporaryDirectory() as tmpdir
:
24 self
.assertTrue(os
.path
.isdir(tmpdir
))
26 raise RuntimeError("message")
28 self
.assertIsNotNone(dirname
)
29 self
.assertFalse(os
.path
.exists(dirname
))