diff --git a/tests/test_git.py b/tests/test_git.py
index <HASH>..<HASH> 100644
--- a/tests/test_git.py
+++ b/tests/test_git.py
@@ -16,12 +16,11 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
-from contextlib import (closing, contextmanager)
+from contextlib import contextmanager
 from os import path
-from shutil import rmtree
 from subprocess import CalledProcessError
 from tarfile import open as open_tar
-from tempfile import mkdtemp
+from tempfile import TemporaryDirectory
 
 from expecter import expect
 
@@ -42,13 +41,10 @@ def tarball_data(tar_name):
     :see: `tar_name`
     """
     data_dir = path.join(path.dirname(__file__), 'data', 'git')
-    with closing(open_tar(path.join(data_dir, tar_name + '.tar'))) as tar:
-        try:
-            temp_dir = mkdtemp()
+    with open_tar(path.join(data_dir, tar_name + '.tar'), 'r:') as tar:
+        with TemporaryDirectory() as temp_dir:
             tar.extractall(temp_dir)
             yield str(path.join(temp_dir, tar_name))
-        finally:
-            rmtree(temp_dir)
 
 
 @requires_git
Use tempfile.TemporaryDirectory

Supported since <I>.