
This is an ongoing series of commits that are reformatting our Python code. Reformatting is done with `black`. If you end up having problems merging this commit because you have made changes to a python file, the best way to handle that is to run git checkout --ours <yourfile> and then reformat it with black. If you run into any problems, post to discourse about it and we will try to help. RFC Thread below: https://discourse.llvm.org/t/rfc-document-and-standardize-python-code-style Reviewed By: MatzeB Differential Revision: https://reviews.llvm.org/D150761
30 lines
993 B
Python
30 lines
993 B
Python
# -*- coding: utf-8 -*-
|
|
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
# See https://llvm.org/LICENSE.txt for license information.
|
|
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
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))
|