Source: software-properties Severity: important Tags: patch Several autopkgtests in software-properties have always failed on ci.debian.net and other minimal environments (as far as I can tell), making them difficult to use as an acceptance test for other changes like the patch I sent to #836041 today.
Please consider the attached patch 0003-d-p-03_no-launchpad.patch-Skip-Launchpad-PPA-tests-w.patch, which extends debian/patches/03_no-launchpad.patch to skip PPA-related parts of the test suite if python3-launchpadlib isn't installed. The updated version of debian/patches/03_no-launchpad.patch is also attached for maybe easier review (avoiding diff-of-diffs). With that change, software-properties builds successfully and passes autopkgtests in testing. I haven't otherwise tested the resulting package. It does not build successfully and will probably still fail autopkgtests in unstable, due to #1079522, but that isn't a regression with the change I'm proposing here. (See also #1054875, #1070068 which are caused by 03_no-launchpad.patch, and are not resolved by this change.) Thanks, smcv
>From 92527c674aa589d9e35693c25b75a09856a69985 Mon Sep 17 00:00:00 2001 From: Simon McVittie <s...@debian.org> Date: Sat, 24 Aug 2024 14:56:39 +0100 Subject: [PATCH 3/3] d/p/03_no-launchpad.patch: Skip Launchpad PPA tests without launchpadlib Otherwise the tests that exercise PPA support will always fail on ci.debian.net or similar test environments with minimal dependencies. Closes: #-1 --- debian/patches/03_no-launchpad.patch | 64 ++++++++++++++++++++-------- 1 file changed, 47 insertions(+), 17 deletions(-) diff --git a/debian/patches/03_no-launchpad.patch b/debian/patches/03_no-launchpad.patch index 996edbf9..bc5e5561 100644 --- a/debian/patches/03_no-launchpad.patch +++ b/debian/patches/03_no-launchpad.patch @@ -1,17 +1,19 @@ -From 8163fc1c2c0c3b74b86a801d1b3c3bf7d8757fc6 Mon Sep 17 00:00:00 2001 From: Matthias Klumpp <m...@debian.org> Date: Sun, 8 Jan 2023 23:28:12 +0100 -Subject: [PATCH] Disable Launchpad support +Subject: Disable Launchpad support This is only used for PPA support, which should be inert on Debian anyway. + +Skip Launchpad tests if launchpadlib is unavailable. --- - softwareproperties/ppa.py | 8 +++++++- - tests/test_shortcuts.py | 8 +++++++- - 2 files changed, 14 insertions(+), 2 deletions(-) + softwareproperties/ppa.py | 8 +++++++- + tests/test_add_apt_repository.py | 6 ++++++ + tests/test_shortcuts.py | 8 +++++++- + 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/softwareproperties/ppa.py b/softwareproperties/ppa.py -index eb4f3717..39f738f5 100644 +index eb4f371..39f738f 100644 --- a/softwareproperties/ppa.py +++ b/softwareproperties/ppa.py @@ -22,7 +22,6 @@ @@ -43,8 +45,32 @@ index eb4f3717..39f738f5 100644 if not self._lp: if self._lp_anon: login_func = Launchpad.login_anonymously +diff --git a/tests/test_add_apt_repository.py b/tests/test_add_apt_repository.py +index 45f4de7..7eb2867 100755 +--- a/tests/test_add_apt_repository.py ++++ b/tests/test_add_apt_repository.py +@@ -17,6 +17,11 @@ from urllib.error import (URLError, HTTPError) + from softwareproperties.cloudarchive import RELEASE_MAP + from softwareproperties.extendedsourceslist import SourceEntry + ++try: ++ from launchpadlib.launchpad import Launchpad ++except ImportError as e: ++ Launchpad = None ++ + + CODENAME = get_distro().codename + +@@ -324,6 +329,7 @@ class TestAddAptRepository(unittest.TestCase): + self.noupdate = True + self.test_sourceslist() + ++ @unittest.skipUnless(Launchpad is not None, "requires launchpadlib") + @unittest.skipUnless(has_network(), 'requires network') + def test_ppa(self, /, with_param=True, prefix=False): + self.testing_ppa = True diff --git a/tests/test_shortcuts.py b/tests/test_shortcuts.py -index 7c1fe143..4e0e7c21 100644 +index 7c1fe14..985aa39 100644 --- a/tests/test_shortcuts.py +++ b/tests/test_shortcuts.py @@ -10,10 +10,13 @@ from aptsources.distro import get_distro @@ -70,15 +96,19 @@ index 7c1fe143..4e0e7c21 100644 _lp = Launchpad.login_anonymously(*args, **kwargs) lp = Mock(wraps=_lp) -@@ -190,6 +194,8 @@ class ShortcutsTestcase(unittest.TestCase): +@@ -176,6 +180,7 @@ class ShortcutsTestcase(unittest.TestCase): + for shortcut in self.create_handlers(uri, URIShortcutHandler): + self.check_shortcut(shortcut, line, sourcefile=URI_SOURCEFILE) + ++ @unittest.skipUnless(Launchpad is not None, "requires launchpadlib") + @unittest.skipUnless(has_network(), "requires network") + def test_shortcut_ppa(self): + for ppa in VALID_PPAS: +@@ -186,6 +191,7 @@ class ShortcutsTestcase(unittest.TestCase): + netrcfile=PPA_NETRCFILE, + trustedcontent=True) + ++ @unittest.skipUnless(Launchpad is not None, "requires launchpadlib") + @unittest.skipUnless(has_network(), "requires network") def test_shortcut_private_ppa(self): # this is the same tests as the public ppa, but login=True will use the mocked lp instance - # this *does not* actually test/verify this works with a real private ppa; that must be done manually -+ if not Launchpad: -+ return - with patch('launchpadlib.launchpad.Launchpad.login_with', new=mock_login_with): - for ppa in VALID_PPAS: - for shortcut in self.create_handlers(ppa, PPAShortcutHandler, login=True): --- -2.39.0 - -- 2.45.2
From: Matthias Klumpp <m...@debian.org> Date: Sun, 8 Jan 2023 23:28:12 +0100 Subject: Disable Launchpad support This is only used for PPA support, which should be inert on Debian anyway. Skip Launchpad tests if launchpadlib is unavailable. --- softwareproperties/ppa.py | 8 +++++++- tests/test_add_apt_repository.py | 6 ++++++ tests/test_shortcuts.py | 8 +++++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/softwareproperties/ppa.py b/softwareproperties/ppa.py index eb4f371..39f738f 100644 --- a/softwareproperties/ppa.py +++ b/softwareproperties/ppa.py @@ -22,7 +22,6 @@ from gettext import gettext as _ -from launchpadlib.launchpad import Launchpad from lazr.restfulclient.errors import (NotFound, BadRequest, Unauthorized) from softwareproperties.shortcuthandler import (ShortcutHandler, ShortcutException, @@ -32,6 +31,11 @@ from softwareproperties.uri import URIShortcutHandler from urllib.parse import urlparse +try: + from launchpadlib.launchpad import Launchpad +except ImportError as e: + Launchpad = None + PPA_URI_FORMAT = 'https://ppa.launchpadcontent.net/{team}/{ppa}/ubuntu/' PRIVATE_PPA_URI_FORMAT = 'https://private-ppa.launchpadcontent.net/{team}/{ppa}/ubuntu/' @@ -90,6 +94,8 @@ class PPAShortcutHandler(ShortcutHandler): @property def lp(self): + if not Launchpad: + return None if not self._lp: if self._lp_anon: login_func = Launchpad.login_anonymously diff --git a/tests/test_add_apt_repository.py b/tests/test_add_apt_repository.py index 45f4de7..7eb2867 100755 --- a/tests/test_add_apt_repository.py +++ b/tests/test_add_apt_repository.py @@ -17,6 +17,11 @@ from urllib.error import (URLError, HTTPError) from softwareproperties.cloudarchive import RELEASE_MAP from softwareproperties.extendedsourceslist import SourceEntry +try: + from launchpadlib.launchpad import Launchpad +except ImportError as e: + Launchpad = None + CODENAME = get_distro().codename @@ -324,6 +329,7 @@ class TestAddAptRepository(unittest.TestCase): self.noupdate = True self.test_sourceslist() + @unittest.skipUnless(Launchpad is not None, "requires launchpadlib") @unittest.skipUnless(has_network(), 'requires network') def test_ppa(self, /, with_param=True, prefix=False): self.testing_ppa = True diff --git a/tests/test_shortcuts.py b/tests/test_shortcuts.py index 7c1fe14..985aa39 100644 --- a/tests/test_shortcuts.py +++ b/tests/test_shortcuts.py @@ -10,10 +10,13 @@ from aptsources.distro import get_distro from softwareproperties.extendedsourceslist import SourceEntry from contextlib import contextmanager from http.client import HTTPException -from launchpadlib.launchpad import Launchpad from urllib.request import urlopen from urllib.error import URLError from unittest.mock import (patch, Mock) +try: + from launchpadlib.launchpad import Launchpad +except ImportError as e: + Launchpad = None sys.path.insert(0, "..") @@ -74,6 +77,7 @@ def has_network(): return True def mock_login_with(*args, **kwargs): + assert Launchpad _lp = Launchpad.login_anonymously(*args, **kwargs) lp = Mock(wraps=_lp) @@ -176,6 +180,7 @@ class ShortcutsTestcase(unittest.TestCase): for shortcut in self.create_handlers(uri, URIShortcutHandler): self.check_shortcut(shortcut, line, sourcefile=URI_SOURCEFILE) + @unittest.skipUnless(Launchpad is not None, "requires launchpadlib") @unittest.skipUnless(has_network(), "requires network") def test_shortcut_ppa(self): for ppa in VALID_PPAS: @@ -186,6 +191,7 @@ class ShortcutsTestcase(unittest.TestCase): netrcfile=PPA_NETRCFILE, trustedcontent=True) + @unittest.skipUnless(Launchpad is not None, "requires launchpadlib") @unittest.skipUnless(has_network(), "requires network") def test_shortcut_private_ppa(self): # this is the same tests as the public ppa, but login=True will use the mocked lp instance