Refactor a few tests to use the new requires_zlib decorator.

This commit is contained in:
Ezio Melotti 2011-05-19 22:03:22 +03:00
parent cad648cbc9
commit 975077a889
5 changed files with 49 additions and 79 deletions

View file

@ -11,12 +11,6 @@ support.requires(
'test requires loads of disk-space bytes and a long time to run'
)
# We can test part of the module without zlib.
try:
import zlib
except ImportError:
zlib = None
import zipfile, os, unittest
import time
import sys
@ -24,7 +18,7 @@ import sys
from io import StringIO
from tempfile import TemporaryFile
from test.support import TESTFN, run_unittest
from test.support import TESTFN, run_unittest, requires_zlib
TESTFN2 = TESTFN + "2"
@ -81,12 +75,12 @@ class TestsWithSourceFile(unittest.TestCase):
for f in TemporaryFile(), TESTFN2:
self.zipTest(f, zipfile.ZIP_STORED)
if zlib:
def testDeflated(self):
# Try the temp file first. If we do TESTFN2 first, then it hogs
# gigabytes of disk space for the duration of the test.
for f in TemporaryFile(), TESTFN2:
self.zipTest(f, zipfile.ZIP_DEFLATED)
@requires_zlib
def testDeflated(self):
# Try the temp file first. If we do TESTFN2 first, then it hogs
# gigabytes of disk space for the duration of the test.
for f in TemporaryFile(), TESTFN2:
self.zipTest(f, zipfile.ZIP_DEFLATED)
def tearDown(self):
for fname in TESTFN, TESTFN2: