From 2e3ef2e42988ec4976cb76fcaa1927bedc16cd7c Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Tue, 28 May 2024 12:21:19 -0400 Subject: [PATCH] Patch lzma and bz2 modules to allow tests to pass. --- conftest.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) 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()