From 1af9fdd2124547099eb0cf5a71b513ef5592dbf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Zatloukal?= Date: Tue, 10 Aug 2021 00:00:50 +0200 Subject: [PATCH] Tests: Use native TemporaryDirectory Without ugly wrapper for Py < 3.2 that doesn't work half of the times... --- js/src/jit-test/jit_test.py | 2 +- js/src/tests/jstests.py | 2 +- js/src/tests/lib/tempfile.py | 16 +--------------- 3 files changed, 3 insertions(+), 17 deletions(-) diff --git a/js/src/jit-test/jit_test.py b/js/src/jit-test/jit_test.py index d9f08a7..1824dee 100755 --- a/js/src/jit-test/jit_test.py +++ b/js/src/jit-test/jit_test.py @@ -28,7 +28,7 @@ def add_tests_dir_to_path(): add_tests_dir_to_path() from lib import jittests -from lib.tempfile import TemporaryDirectory +from tempfile import TemporaryDirectory from lib.tests import ( change_env, get_cpu_count, diff --git a/js/src/tests/jstests.py b/js/src/tests/jstests.py index cc11c3d..fff7857 100755 --- a/js/src/tests/jstests.py +++ b/js/src/tests/jstests.py @@ -27,7 +27,7 @@ from subprocess import call, list2cmdline from lib.adaptor import xdr_annotate from lib.progressbar import ProgressBar from lib.results import ResultsSink, TestOutput -from lib.tempfile import TemporaryDirectory +from tempfile import TemporaryDirectory from lib.tests import ( RefTestCase, change_env, diff --git a/js/src/tests/lib/tempfile.py b/js/src/tests/lib/tempfile.py index 604864d..b791387 100644 --- a/js/src/tests/lib/tempfile.py +++ b/js/src/tests/lib/tempfile.py @@ -1,18 +1,4 @@ # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -try: - # Python 3.2 - from tempfile import TemporaryDirectory -except ImportError: - import shutil - import tempfile - from contextlib import contextmanager - - @contextmanager - def TemporaryDirectory(*args, **kwds): - d = tempfile.mkdtemp(*args, **kwds) - try: - yield d - finally: - shutil.rmtree(d) +from tempfile import TemporaryDirectory -- 2.41.0