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] 4d76bd160f

Change-Id: I6cc3bedaa9753dc86d6560d32961b5a22cf3a36e
This commit is contained in:
Erik Berg 2022-04-11 20:11:09 +02:00 committed by Clark Boylan
parent d23778fcd7
commit 186f6e4035
2 changed files with 9 additions and 2 deletions

View File

@ -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'))

View File

@ -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'