Commit 609921a3 authored by Vincent Pelletier's avatar Vincent Pelletier

caucase.test: Fix tarfile deprecation warning

parent 05515f9f
......@@ -84,6 +84,18 @@ from caucase.storage import SQLite3Storage
_cryptography_backend = default_backend()
if hasattr(tarfile, 'data_filter'): # pragma: no cover
# Silence a deprecation warning on Python 3.12
class TarFile(tarfile.TarFile):
"""
tarball.TarFile with the future default filter.
Used to silence a deprecation warning.
"""
extraction_filter = staticmethod(tarfile.data_filter)
else: # pragma: no cover
TarFile = tarfile.TarFile
def _getTestOID():
"""
Some cryptography versions do not tolerate large OIDs. Detect these here.
......@@ -463,14 +475,14 @@ class CaucaseTest(TestCase):
self._startServer(timeout=60)
self._stopServer()
server_raw = BytesIO()
with tarfile.TarFile(mode='w', fileobj=server_raw) as server_tarball:
with TarFile(mode='w', fileobj=server_raw) as server_tarball:
server_tarball.add(
self._server_dir,
arcname=os.path.basename(self._server_dir),
)
_clean_caucased_snapshot = server_raw.getvalue()
else:
with tarfile.TarFile(
with TarFile(
mode='r',
fileobj=BytesIO(_clean_caucased_snapshot),
) as server_tarball:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment