mirror of
https://github.com/python/cpython.git
synced 2025-12-09 10:37:17 +00:00
Issue #18223: Refactor test_tarfile.
* Use mixins for generating tests for different compression types. * Make test_tarfile discoverable. * Use more special tests (i.e. assertEqual, assertIs) instead of assertTrue. * Add explicit test skips instead of reporting skipped tests as passed. * Wrap long lines. * Correct a comment for test_hardlink_extraction1. * Add support.requires_gzip. * Replace ImportError by ModuleNotFoundError. and some other minor enhancements.
This commit is contained in:
commit
78be6e8aa3
2 changed files with 346 additions and 382 deletions
|
|
@ -42,6 +42,11 @@ try:
|
||||||
except ModuleNotFoundError:
|
except ModuleNotFoundError:
|
||||||
zlib = None
|
zlib = None
|
||||||
|
|
||||||
|
try:
|
||||||
|
import gzip
|
||||||
|
except ModuleNotFoundError:
|
||||||
|
gzip = None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import bz2
|
import bz2
|
||||||
except ModuleNotFoundError:
|
except ModuleNotFoundError:
|
||||||
|
|
@ -71,7 +76,7 @@ __all__ = [
|
||||||
"TestHandler", "Matcher", "can_symlink", "skip_unless_symlink",
|
"TestHandler", "Matcher", "can_symlink", "skip_unless_symlink",
|
||||||
"skip_unless_xattr", "import_fresh_module", "requires_zlib",
|
"skip_unless_xattr", "import_fresh_module", "requires_zlib",
|
||||||
"PIPE_MAX_SIZE", "failfast", "anticipate_failure", "run_with_tz",
|
"PIPE_MAX_SIZE", "failfast", "anticipate_failure", "run_with_tz",
|
||||||
"requires_bz2", "requires_lzma", "suppress_crash_popup",
|
"requires_gzip", "requires_bz2", "requires_lzma", "suppress_crash_popup",
|
||||||
]
|
]
|
||||||
|
|
||||||
class Error(Exception):
|
class Error(Exception):
|
||||||
|
|
@ -590,6 +595,8 @@ requires_IEEE_754 = unittest.skipUnless(
|
||||||
|
|
||||||
requires_zlib = unittest.skipUnless(zlib, 'requires zlib')
|
requires_zlib = unittest.skipUnless(zlib, 'requires zlib')
|
||||||
|
|
||||||
|
requires_gzip = unittest.skipUnless(gzip, 'requires gzip')
|
||||||
|
|
||||||
requires_bz2 = unittest.skipUnless(bz2, 'requires bz2')
|
requires_bz2 = unittest.skipUnless(bz2, 'requires bz2')
|
||||||
|
|
||||||
requires_lzma = unittest.skipUnless(lzma, 'requires lzma')
|
requires_lzma = unittest.skipUnless(lzma, 'requires lzma')
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue