From 467d2ebecdb1b9da1c4294aaa0ebcf085c5d5db0 Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Tue, 12 Feb 2019 23:17:36 -0800 Subject: [PATCH] Fix unit tests on Python 3.8. --- test/units/module_utils/network/aci/test_aci.py | 2 ++ test/units/module_utils/test_distro.py | 7 +++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/test/units/module_utils/network/aci/test_aci.py b/test/units/module_utils/network/aci/test_aci.py index 64bccbadbf0..804d405ca03 100644 --- a/test/units/module_utils/network/aci/test_aci.py +++ b/test/units/module_utils/network/aci/test_aci.py @@ -261,6 +261,8 @@ class AciRest(unittest.TestCase): error_text = to_native(u"Unable to parse output as XML, see 'raw' output. None (line 0)", errors='surrogate_or_strict') elif PY2: error_text = "Unable to parse output as XML, see 'raw' output. Document is empty, line 1, column 1 (line 1)" + elif sys.version_info >= (3, 8): + error_text = "Unable to parse output as XML, see 'raw' output. None (line 0)" else: error_text = "Unable to parse output as XML, see 'raw' output. Document is empty, line 1, column 1 (, line 1)" diff --git a/test/units/module_utils/test_distro.py b/test/units/module_utils/test_distro.py index 37e647e2ae8..f44729c1916 100644 --- a/test/units/module_utils/test_distro.py +++ b/test/units/module_utils/test_distro.py @@ -14,6 +14,7 @@ import platform import pytest +import sys from ansible.module_utils import distro from ansible.module_utils.common.sys_info import (get_distribution, get_distribution_version, @@ -40,13 +41,11 @@ class TestDistro(): # distro result is what we expect and special cased. class TestDistroCompat(): '''Verify that distro.linux_distribution matches plain platform.linux_distribution''' - - _platform_supported_dists = platform._supported_dists - + @pytest.mark.skipif(sys.version_info >= (3, 8), reason="Python 3.8 and later do not have platform.linux_distribution().") def test_linux_distribution(self): distro_linux_dist = (get_distribution(), get_distribution_version(), get_distribution_codename()) - platform_linux_dist = platform.linux_distribution(supported_dists=self._platform_supported_dists) + platform_linux_dist = platform.linux_distribution() assert isinstance(distro_linux_dist, type(platform_linux_dist)), \ 'linux_distribution() returned type (%s) which is different from platform.linux_distribution type (%s)' % \