File: tests-Try-to-use-TemporaryDirectory-from-Python-standard-.patch

package info (click to toggle)
bmap-tools 3.6-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 936 kB
  • sloc: python: 5,078; sh: 117; makefile: 8
file content (49 lines) | stat: -rw-r--r-- 1,907 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
From: Simon McVittie <smcv@debian.org>
Date: Thu, 28 Oct 2021 11:05:52 +0100
Subject: tests: Try to use TemporaryDirectory from Python standard library

This avoids an unnecessary external dependency with Python >= 3.2.

Signed-off-by: Simon McVittie <smcv@debian.org>
Forwarded: https://github.com/intel/bmap-tools/pull/87
Applied-upstream: 3.7, commit:dfba9f9c664c240bbf339189bf7abd7314bcafbc
---
 requirements-test.txt      | 2 +-
 tests/test_bmap_helpers.py | 7 +++++--
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/requirements-test.txt b/requirements-test.txt
index cea340a..f83802d 100644
--- a/requirements-test.txt
+++ b/requirements-test.txt
@@ -1,4 +1,4 @@
 six
 nose
-backports.tempfile
+backports.tempfile ; python_version < '3.2'
 mock ; python_version < '3.3'
diff --git a/tests/test_bmap_helpers.py b/tests/test_bmap_helpers.py
index 47b3862..56b079e 100644
--- a/tests/test_bmap_helpers.py
+++ b/tests/test_bmap_helpers.py
@@ -25,7 +25,10 @@ try:
     from unittest.mock import patch, mock
 except ImportError:     # for Python < 3.3
     from mock import patch, mock
-from backports import tempfile as btempfile
+try:
+    from tempfile import TemporaryDirectory
+except ImportError:     # for Python < 3.2
+    from backports.tempfile import TemporaryDirectory
 from bmaptools import BmapHelpers
 
 
@@ -58,7 +61,7 @@ class TestBmapHelpers(unittest.TestCase):
     def test_get_file_system_type_symlink(self):
         """Check a file system type is returned when used with a symlink"""
 
-        with btempfile.TemporaryDirectory(prefix="testdir_", dir=".") as directory:
+        with TemporaryDirectory(prefix="testdir_", dir=".") as directory:
             fobj = tempfile.NamedTemporaryFile("r", prefix="testfile_", delete=False,
                                             dir=directory, suffix=".img")
             lnk = os.path.join(directory, "test_symlink")