Enable most unittests on python3 (just some vault unittests and a logging one left) (#17240)

Make some python3 fixes to make the unittests pass:

* galaxy imports
* dictionary iteration in role requirements
* swap_stdout helper for unittests
* Normalize to text string in a facts.py function
This commit is contained in:
Toshio Kuratomi 2016-08-25 07:30:03 -07:00 committed by GitHub
parent c2d87816a8
commit 44d979c8f5
11 changed files with 23 additions and 29 deletions

View file

@ -30,6 +30,7 @@ from ansible.compat.tests import unittest
from ansible.compat.tests.mock import patch
# the module we are actually testing
import ansible.module_utils.facts as facts
# to generate the testcase data, you can use the script gen_distribution_version_testcase.py in hacking/tests
@ -621,7 +622,7 @@ DISTRIB_DESCRIPTION="CoreOS 976.0.0 (Coeur Rouge)"
]
@unittest.skipIf(sys.version_info[0] >= 3, "Python 3 is not supported on targets (yet)")
def test_distribution_version():
"""tests the distribution parsing code of the Facts class
@ -634,9 +635,6 @@ def test_distribution_version():
* results for the ansible variables distribution*
"""
# needs to be in here, because the import fails with python3 still
import ansible.module_utils.facts as facts
from ansible.module_utils import basic
args = json.dumps(dict(ANSIBLE_MODULE_ARGS={}))