diff --git a/tests/test_gzip_compliance.py b/tests/test_gzip_compliance.py index 5d71577c..bca9fd40 100644 --- a/tests/test_gzip_compliance.py +++ b/tests/test_gzip_compliance.py @@ -65,14 +65,11 @@ def seek(self, *args): class BaseTest(unittest.TestCase): - def __init__(self, methodName): + def setUp(self): + # Make a unique file name. The tests create the file themselves. fileno, self.filename = tempfile.mkstemp() os.close(fileno) - super().__init__(methodName) - - def setUp(self): - if os.path.exists(self.filename): - os.unlink(self.filename) + os.unlink(self.filename) def tearDown(self): if os.path.exists(self.filename): diff --git a/tests/test_igzip.py b/tests/test_igzip.py index 4f0e44f3..f185ac80 100644 --- a/tests/test_igzip.py +++ b/tests/test_igzip.py @@ -14,7 +14,6 @@ import itertools import os import re -import shutil import struct import subprocess import sys @@ -39,11 +38,9 @@ def test_wrong_compresslevel_igzipfile(): error.match("Compression level should be between 0 and 3") -def test_repr(): - tempdir = tempfile.mkdtemp() - with igzip.IGzipFile(os.path.join(tempdir, "test.gz"), "wb") as test: +def test_repr(tmp_path): + with igzip.IGzipFile(str(tmp_path / "test.gz"), "wb") as test: assert "