diff --git a/conftest.py b/conftest.py index 209495f..0aeafb1 100644 --- a/conftest.py +++ b/conftest.py @@ -22,6 +22,36 @@ def backport_as_std(): sys.modules['tarfile'] = tarfile +def patch_bz2(): + """ + Ensure bz2.BZ2File reflects the name. + """ + if sys.version_info > (3, 13): + return + try: + import bz2 + except ImportError: + return + + bz2.BZ2File.name = property(lambda self: self._fp.name) + + +def patch_lzma(): + """ + Ensure lzma.LZMAFile reflects the name. + """ + if sys.version_info > (3, 13): + return + try: + import lzma + except ImportError: + return + + lzma.LZMAFile.name = property(lambda self: self._fp.name) + + def pytest_configure(): patch_findfile() backport_as_std() + patch_bz2() + patch_lzma()