From 18656fc4d39549d95ac012566eafabf53b7e4be3 Mon Sep 17 00:00:00 2001 From: Malcolm Smith Date: Tue, 24 Sep 2024 20:07:28 +0100 Subject: [PATCH 1/3] Make test_unzip_zipfile recognize Android error message format --- Lib/test/test_shutil.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py index 80e1d73b6b2aab..d5eeaf46b8bccb 100644 --- a/Lib/test/test_shutil.py +++ b/Lib/test/test_shutil.py @@ -13,6 +13,7 @@ import pathlib import subprocess import random +import re import string import contextlib import io @@ -1909,7 +1910,7 @@ def test_unzip_zipfile(self): subprocess.check_output(zip_cmd, stderr=subprocess.STDOUT) except subprocess.CalledProcessError as exc: details = exc.output.decode(errors="replace") - if 'unrecognized option: t' in details: + if re.search(r'(unrecognized|invalid) option(:| --) t', details): self.skipTest("unzip doesn't support -t") msg = "{}\n\n**Unzip Output**\n{}" self.fail(msg.format(exc, details)) From 54fcccf46f5a7a250dae3cdfb5bda603fa1936e1 Mon Sep 17 00:00:00 2001 From: Malcolm Smith Date: Wed, 25 Sep 2024 13:19:22 +0100 Subject: [PATCH 2/3] Replace regex with a simple list of strings --- Lib/test/test_shutil.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py index d5eeaf46b8bccb..6fd76b5374129a 100644 --- a/Lib/test/test_shutil.py +++ b/Lib/test/test_shutil.py @@ -13,7 +13,6 @@ import pathlib import subprocess import random -import re import string import contextlib import io @@ -1910,7 +1909,10 @@ def test_unzip_zipfile(self): subprocess.check_output(zip_cmd, stderr=subprocess.STDOUT) except subprocess.CalledProcessError as exc: details = exc.output.decode(errors="replace") - if re.search(r'(unrecognized|invalid) option(:| --) t', details): + if any(message in details for message in [ + 'unrecognized option: t', # Info-ZIP + 'invalid option -- t', # Android + ]): self.skipTest("unzip doesn't support -t") msg = "{}\n\n**Unzip Output**\n{}" self.fail(msg.format(exc, details)) From f4e9207f6dc4210fa70325dd0ec5545fb44ab0da Mon Sep 17 00:00:00 2001 From: Malcolm Smith Date: Wed, 25 Sep 2024 13:30:37 +0100 Subject: [PATCH 3/3] Correct comment --- Lib/test/test_shutil.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py index 6fd76b5374129a..37e54d23b22516 100644 --- a/Lib/test/test_shutil.py +++ b/Lib/test/test_shutil.py @@ -1910,7 +1910,7 @@ def test_unzip_zipfile(self): except subprocess.CalledProcessError as exc: details = exc.output.decode(errors="replace") if any(message in details for message in [ - 'unrecognized option: t', # Info-ZIP + 'unrecognized option: t', # BusyBox 'invalid option -- t', # Android ]): self.skipTest("unzip doesn't support -t")