Skip to content

Commit

Permalink
Patch lzma and bz2 modules to allow tests to pass.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed May 28, 2024
1 parent 3f68667 commit 2e3ef2e
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit 2e3ef2e

Please sign in to comment.