-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix unit test on Python 3.8 #56031
Fix unit test on Python 3.8 #56031
Conversation
fb6cfa7
to
cc541a2
Compare
I pushed more commits to fix all Python 3.8 related unit tests failures. |
FYI, I also did some work on this here. |
I picked the commits from your branch that I haven't addressed yet. |
Apply saltstack/salt#56031 to support Python 3.8, which removed a deprecated module and changed some behaviour. Add a {Build,}Requires on python-distro, since it is now required.
Apply saltstack/salt#56031 to support Python 3.8, which removed a deprecated module and changed some behaviour. Add a {Build,}Requires on python-distro, since it is now required.
3833c85
to
bc40225
Compare
Apply saltstack#56031 to support Python 3.8, which removed a deprecated module and changed some behaviour. Add a {Build,}Requires on python-distro, since it is now required.
Apply saltstack/salt#56031 to support Python 3.8, which removed a deprecated module and changed some behaviour. Add a {Build,}Requires on python-distro, since it is now required.
Apply saltstack/salt#56031 to support Python 3.8, which removed a deprecated module and changed some behaviour. Add a {Build,}Requires on python-distro, since it is now required.
Apply saltstack/salt#56031 to support Python 3.8, which removed a deprecated module and changed some behaviour. Add a {Build,}Requires on python-distro, since it is now required.
Apply saltstack/salt#56031 to support Python 3.8, which removed a deprecated module and changed some behaviour. Add a {Build,}Requires on python-distro, since it is now required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bdrung thanks for doing this! You’re really close. Just need to get the Windows and Mac test working. Once you have that I think this PR will be good to merge.
54487c4
to
35d5b2a
Compare
The failing Windows and Mac tests are identical with the failings tests of the master branch. So this merge request does not introduce any regression. |
b9e1609
to
3f34672
Compare
I rebased this patch set on master to resolve the merge commits. This rebase dropped some commits which are already part of the master branch. |
It has some lint issues that need fixing now |
DeprecationWarning: Using or importing the ABCs from `collections` instead of from `collections.abc` is deprecated since Python 3.3, and in 3.9 it will stop working. Therefore try to import the abstract base classes from `collections.abc` before falling back to `collections`. Signed-off-by: Benjamin Drung <[email protected]>
Salt fails on Python 3.8: ``` ====================================================================== ERROR: unit.grains.test_core (unittest.loader._FailedTest) ---------------------------------------------------------------------- ImportError: Failed to import test module: unit.grains.test_core Traceback (most recent call last): File "/usr/lib/python3.8/unittest/loader.py", line 436, in _find_test_path module = self._get_module_from_name(name) File "/usr/lib/python3.8/unittest/loader.py", line 377, in _get_module_from_name __import__(name) File "tests/unit/grains/test_core.py", line 37, in <module> import salt.grains.core as core File "salt/grains/core.py", line 40, in <module> from platform import _supported_dists ImportError: cannot import name '_supported_dists' from 'platform' (/usr/lib/python3.8/platform.py) ``` So only try to import `_supported_dists` from `platform` for Python <= 3.7. Otherwise rely on the external `distro` module to not need any special handling. Addresses parts of saltstack#55835 Signed-off-by: Benjamin Drung <[email protected]>
The following unit tests fail on Python 3.8: ``` ====================================================================== ERROR: test_state_config (unit.renderers.test_stateconf.StateConfigRendererTestCase) [CPU:0.0%|MEM:56.6%] ---------------------------------------------------------------------- Traceback (most recent call last): File "/<<PKGBUILDDIR>>/tests/unit/renderers/test_stateconf.py", line 74, in test_state_config result = self._render_sls(''' File "/<<PKGBUILDDIR>>/tests/unit/renderers/test_stateconf.py", line 66, in _render_sls return self._renderers['stateconf']( File "/<<PKGBUILDDIR>>/salt/renderers/stateconf.py", line 227, in render for k in six.iterkeys(tmplctx): # iterate over a copy of keys RuntimeError: dictionary keys changed during iteration ====================================================================== ERROR: test_apply_cloud_providers_config_extend (unit.test_config.ConfigTestCase) [CPU:0.0%|MEM:56.6%] ---------------------------------------------------------------------- Traceback (most recent call last): File "/<<PKGBUILDDIR>>/tests/unit/test_config.py", line 1243, in test_apply_cloud_providers_config_extend salt.config.apply_cloud_providers_config( File "/<<PKGBUILDDIR>>/salt/config/__init__.py", line 3196, in apply_cloud_providers_config for driver, details in six.iteritems(entries): RuntimeError: dictionary keys changed during iteration ====================================================================== ERROR: test_apply_cloud_providers_config_extend_multiple (unit.test_config.ConfigTestCase) [CPU:0.0%|MEM:56.6%] ---------------------------------------------------------------------- Traceback (most recent call last): File "/<<PKGBUILDDIR>>/tests/unit/test_config.py", line 1334, in test_apply_cloud_providers_config_extend_multiple self.assertEqual(ret, salt.config.apply_cloud_providers_config(overrides, defaults=DEFAULT)) File "/<<PKGBUILDDIR>>/salt/config/__init__.py", line 3196, in apply_cloud_providers_config for driver, details in six.iteritems(entries): RuntimeError: dictionary keys changed during iteration ====================================================================== ``` Replace the affected for loop of the first case by a dictionary comprehension to construct the modified dictionary. For the remaining cases, switch from `iteritems` to `iterkeys`, since the dictionary values will be modified. Signed-off-by: Benjamin Drung <[email protected]>
The test case `unit.modules.test_virt.VirtTestCase.test_update` fails on Ubuntu 20.04 with Python 3.8: ``` ====================================================================== FAIL: test_update (unit.modules.test_virt.VirtTestCase) [CPU:0.0%|MEM:17.0%] ---------------------------------------------------------------------- Traceback (most recent call last): File "tests/unit/modules/test_virt.py", line 1313, in test_update self.assertEqual({ AssertionError: {'definition': False, 'disk': {'attached': [], 'detached[49 chars] []}} != {'definition': True, 'disk': {'attached': [], 'detached'[74 chars]True} + {'cpu': True, - {'definition': False, ? ^ ^^^^ + 'definition': True, ? ^ ^^^ 'disk': {'attached': [], 'detached': []}, - 'interface': {'attached': [], 'detached': []}} ? ^ + 'interface': {'attached': [], 'detached': []}, ? ^ + 'mem': True} ====================================================================== ``` `virt.update` falsely detects a change to the graphics setting in the "no diff case". The old XML part specifies: ```xml <graphics type="spice" port="5900" autoport="yes" listen="127.0.0.1"> <listen type="address" address="127.0.0.1" /> </graphics> ``` The newly generated XML misses the port setting: ```xml <graphics type="spice" listen="127.0.0.1" autoport="yes"> <listen type="address" address="127.0.0.1" /> </graphics> ``` So adjust the initial XML file of the template, because setting the port to the default 5900, will change `autoport` to `no`. Signed-off-by: Benjamin Drung <[email protected]>
3f34672
to
26d3a77
Compare
Fixed the lint issues. |
This was missed in saltstack#56031.
Apply saltstack/salt#56031 to support Python 3.8, which removed a deprecated module and changed some behaviour. Add a {Build,}Requires on python-distro, since it is now required.
applies to #55835 |
Why did this bother with the try/except on |
Good point. Please open a merge request to drop falling back to the old location. |
Apply saltstack/salt#56031 to support Python 3.8, which removed a deprecated module and changed some behaviour. Add a {Build,}Requires on python-distro, since it is now required.
Apply saltstack#56031 to support Python 3.8, which removed a deprecated module and changed some behaviour. Add a {Build,}Requires on python-distro, since it is now required.
Salt fails on Python 3.8:
So only try to import
_supported_dists
fromplatform
for Python <=3.7. Otherwise rely on the external
distro
module to not need anyspecial handling.
Addresses parts of #55835