From 186f6e4035347804a9b7def28b29e208f882c235 Mon Sep 17 00:00:00 2001 From: Erik Berg Date: Mon, 11 Apr 2022 20:11:09 +0200 Subject: [PATCH] Fix bindep testing with distro 1.7.0 and greater The 1.7.0 release of distro moves the source code around [0] which requires us to update our monkey patching of distro to make tests work. Because distro 1.7.0 does not support python < 3.6 we update bindep's testing to accomodate both old and new distro to enable python 2.7 and 3.5 testing. [0] https://github.com/python-distro/distro/commit/4d76bd160f8ef98dadd260218f2bce42c03435d1 Change-Id: I6cc3bedaa9753dc86d6560d32961b5a22cf3a36e --- bindep/tests/test_depends.py | 8 +++++++- requirements.txt | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/bindep/tests/test_depends.py b/bindep/tests/test_depends.py index 4f86986..01ca29d 100644 --- a/bindep/tests/test_depends.py +++ b/bindep/tests/test_depends.py @@ -54,12 +54,18 @@ class DistroFixture(fixtures.Fixture): self.distro_name = distro_name.lower() def _setUp(self): + # Python 2.7 and 3.5 need older distro which has different src paths + if distro.__version__ < '1.7.0': + distro_patch_path = 'distro._distro' + else: + distro_patch_path = 'distro.distro._distro' # This type of monkey patching is borrowed from the distro test # suite. os_release = os.path.join(FIXTURE_DIR, self.distro_name, 'etc', 'os-release') mydistro = distro.LinuxDistribution(False, os_release, 'non') - self.useFixture(fixtures.MonkeyPatch('distro._distro', mydistro)) + self.useFixture( + fixtures.MonkeyPatch(distro_patch_path, mydistro)) if self.distro_name not in ['darwin']: self.useFixture(fixtures.MonkeyPatch( 'platform.system', lambda *x: 'Linux')) diff --git a/requirements.txt b/requirements.txt index 18ad23b..2431d42 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ -distro +distro<1.7.0 ; python_version < '3.6' +distro>=1.7.0 ; python_version >= '3.6' pbr>=2.0.0 # Apache-2.0 Parsley packaging ; python_version >= '3.6'