diff options
Diffstat (limited to 'setuptools/tests/py26compat.py')
| -rw-r--r-- | setuptools/tests/py26compat.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/setuptools/tests/py26compat.py b/setuptools/tests/py26compat.py index d4fb891a..24e6dbe2 100644 --- a/setuptools/tests/py26compat.py +++ b/setuptools/tests/py26compat.py @@ -1,4 +1,6 @@ +import sys import unittest +import tarfile try: # provide skipIf for Python 2.4-2.6 @@ -12,3 +14,13 @@ except AttributeError: return skip return func return skipper + +def _tarfile_open_ex(*args, **kwargs): + """ + Extend result with an __exit__ to close the file. + """ + res = tarfile.open(*args, **kwargs) + res.__exit__ = lambda self: self.close() + return res + +tarfile_open = _tarfile_open_ex if sys.version_info < (2,7) else tarfile.open |
