Use filter argument with shutil.unpack_archive for python 3.12
Hanno Böck

Hanno Böck commited on 2023-10-30 08:20:17
Zeige 1 geänderte Dateien mit 6 Einfügungen und 0 Löschungen.


In python 3.12, not using the filter argument will raise a warning.
Unfortunately, we need to also check for zip files separately,
as those do not support the filter argument.
... ...
@@ -6,6 +6,7 @@ import tempfile
6 6
 import shutil
7 7
 import re
8 8
 import difflib
9
+import sys
9 10
 
10 11
 TESTDATA_REPO = "https://github.com/schokokeksorg/freewvs-testdata"
11 12
 
... ...
@@ -26,7 +27,12 @@ class TestFreewvsData(unittest.TestCase):
26 27
             bdir = os.path.basename(tdir)
27 28
             for tarball in glob.glob(tdir + "/dist/*"):
28 29
                 tname = os.path.basename(tarball)
30
+                if sys.version_info < (3, 12) or tarball.endswith(".zip"):
29 31
                     shutil.unpack_archive(tarball, f"{tmp}/{bdir}/{tname}-src")
32
+                else:
33
+                    shutil.unpack_archive(
34
+                        tarball, f"{tmp}/{bdir}/{tname}-src", filter="data"
35
+                    )
30 36
             fwrun = subprocess.run(
31 37
                 ["./freewvs", "-a", tmp + "/" + bdir],
32 38
                 stdout=subprocess.PIPE,
33 39