-
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
Merged
Merged
Fix unit test on Python 3.8 #56031
Commits on Apr 24, 2020
-
Fix deprecation warnings for imports from collections
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]>
Configuration menu - View commit details
-
Copy full SHA for 420bbe8 - Browse repository at this point
Copy the full SHA 420bbe8View commit details -
Support distro.linux_distribution
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]>
Configuration menu - View commit details
-
Copy full SHA for 501a843 - Browse repository at this point
Copy the full SHA 501a843View commit details -
Fix RuntimeError: dictionary keys changed during iteration
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]>
Configuration menu - View commit details
-
Copy full SHA for beaef55 - Browse repository at this point
Copy the full SHA beaef55View commit details -
Fix unit.modules.test_virt.VirtTestCase.test_update
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]>
Configuration menu - View commit details
-
Copy full SHA for f793484 - Browse repository at this point
Copy the full SHA f793484View commit details -
Configuration menu - View commit details
-
Copy full SHA for 01fb8fc - Browse repository at this point
Copy the full SHA 01fb8fcView commit details -
Configuration menu - View commit details
-
Copy full SHA for 26d3a77 - Browse repository at this point
Copy the full SHA 26d3a77View commit details
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.