Skip to content

Commit 6547cbe

Browse files
committed
Remove add_compress_level_flag helper in the test of gzip
1 parent 7bcc2f1 commit 6547cbe

1 file changed

Lines changed: 17 additions & 28 deletions

File tree

Lib/test/test_gzip.py

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -687,19 +687,6 @@ def wrapper(*args, **kwargs):
687687
return decorator
688688

689689

690-
def add_compress_level_flag(*compress_levels):
691-
def decorator(function):
692-
@functools.wraps(function)
693-
def wrapper(*args, **kwargs):
694-
self = args[0]
695-
for compress_level in compress_levels:
696-
with self.subTest(compress_level=compress_level):
697-
kwargs.update(compress_level=compress_level)
698-
function(*args, **kwargs)
699-
return wrapper
700-
return decorator
701-
702-
703690
class TestCommandLine(unittest.TestCase):
704691
data = b'This is a simple test with gzip'
705692

@@ -763,22 +750,24 @@ def test_compress_infile_outfile(self):
763750
self.assertEqual(out, b'')
764751
self.assertEqual(err, b'')
765752

766-
@add_compress_level_flag('--fast', '--best')
767753
@create_and_remove_directory(TEMPDIR)
768-
def test_compress_infile_outfile(self, compress_level):
769-
local_testgzip = os.path.join(TEMPDIR, 'testgzip')
770-
gzipname = local_testgzip + '.gz'
771-
self.assertFalse(os.path.exists(gzipname))
772-
773-
with open(local_testgzip, 'wb') as fp:
774-
fp.write(self.data)
775-
776-
rc, out, err = assert_python_ok('-m', 'gzip', compress_level, local_testgzip)
777-
778-
self.assertTrue(os.path.exists(gzipname))
779-
self.assertEqual(rc, 0)
780-
self.assertEqual(out, b'')
781-
self.assertEqual(err, b'')
754+
def test_compress_infile_outfile(self):
755+
for compress_level in ('--fast', '--best'):
756+
with self.subTest(compress_level=compress_level):
757+
local_testgzip = os.path.join(TEMPDIR, 'testgzip')
758+
gzipname = local_testgzip + '.gz'
759+
self.assertFalse(os.path.exists(gzipname))
760+
761+
with open(local_testgzip, 'wb') as fp:
762+
fp.write(self.data)
763+
764+
rc, out, err = assert_python_ok('-m', 'gzip', compress_level, local_testgzip)
765+
766+
self.assertTrue(os.path.exists(gzipname))
767+
self.assertEqual(out, b'')
768+
self.assertEqual(err, b'')
769+
os.remove(gzipname)
770+
self.assertFalse(os.path.exists(gzipname))
782771

783772
def test_compress_fast_best_are_exclusive(self):
784773
rc, out, err = assert_python_failure('-m', 'gzip', '--fast', '--best')

0 commit comments

Comments
 (0)