Fix ansible-test unicode and sanity tests. (#29743)

* Show warning when using pylint on Python 2.6.
* Add pylint disable entries for Python 2.
* Fix unicode handling in ansible-test.
* Add missing documentation.
pull/30079/head
Matt Clay 7 years ago committed by GitHub
parent b5eca624d0
commit 79bc49e150

@ -0,0 +1 @@
"""Empty placeholder for import sanity test."""

@ -169,7 +169,7 @@ class SanityFailure(TestFailure):
:type test: str :type test: str
:type python_version: str :type python_version: str
:type messages: list[SanityMessage] :type messages: list[SanityMessage]
:type summary: str :type summary: unicode
""" """
super(SanityFailure, self).__init__(COMMAND, test, python_version, messages, summary) super(SanityFailure, self).__init__(COMMAND, test, python_version, messages, summary)
@ -227,7 +227,7 @@ class SanityCodeSmellTest(SanityTest):
status = ex.status status = ex.status
if stderr or status: if stderr or status:
summary = str(SubprocessError(cmd=cmd, status=status, stderr=stderr, stdout=stdout)) summary = u'%s' % SubprocessError(cmd=cmd, status=status, stderr=stderr, stdout=stdout)
return SanityFailure(self.name, summary=summary) return SanityFailure(self.name, summary=summary)
return SanitySuccess(self.name) return SanitySuccess(self.name)

@ -57,14 +57,14 @@ class AnsibleDocTest(SanityMultipleVersion):
status = ex.status status = ex.status
if status: if status:
summary = str(SubprocessError(cmd=cmd, status=status, stderr=stderr)) summary = u'%s' % SubprocessError(cmd=cmd, status=status, stderr=stderr)
return SanityFailure(self.name, summary=summary, python_version=python_version) return SanityFailure(self.name, summary=summary, python_version=python_version)
if stdout: if stdout:
display.info(stdout.strip(), verbosity=3) display.info(stdout.strip(), verbosity=3)
if stderr: if stderr:
summary = 'Output on stderr from ansible-doc is considered an error.\n\n%s' % SubprocessError(cmd, stderr=stderr) summary = u'Output on stderr from ansible-doc is considered an error.\n\n%s' % SubprocessError(cmd, stderr=stderr)
return SanityFailure(self.name, summary=summary, python_version=python_version) return SanityFailure(self.name, summary=summary, python_version=python_version)
return SanitySuccess(self.name, python_version=python_version) return SanitySuccess(self.name, python_version=python_version)

@ -9,11 +9,13 @@ from lib.sanity import (
SanityMessage, SanityMessage,
SanityFailure, SanityFailure,
SanitySuccess, SanitySuccess,
SanitySkipped,
) )
from lib.util import ( from lib.util import (
SubprocessError, SubprocessError,
run_command, run_command,
display,
) )
from lib.ansible_util import ( from lib.ansible_util import (
@ -30,6 +32,10 @@ from lib.test import (
PYLINT_SKIP_PATH = 'test/sanity/pylint/skip.txt' PYLINT_SKIP_PATH = 'test/sanity/pylint/skip.txt'
UNSUPPORTED_PYTHON_VERSIONS = (
'2.6',
)
class PylintTest(SanitySingleVersion): class PylintTest(SanitySingleVersion):
"""Sanity test using pylint.""" """Sanity test using pylint."""
@ -39,6 +45,10 @@ class PylintTest(SanitySingleVersion):
:type targets: SanityTargets :type targets: SanityTargets
:rtype: SanityResult :rtype: SanityResult
""" """
if args.python_version in UNSUPPORTED_PYTHON_VERSIONS:
display.warning('Skipping pylint on unsupported Python version %s.' % args.python_version)
return SanitySkipped(self.name)
with open(PYLINT_SKIP_PATH, 'r') as skip_fd: with open(PYLINT_SKIP_PATH, 'r') as skip_fd:
skip_paths = skip_fd.read().splitlines() skip_paths = skip_fd.read().splitlines()

@ -194,7 +194,7 @@ class TestFailure(TestResult):
:type test: str :type test: str
:type python_version: str | None :type python_version: str | None
:type messages: list[TestMessage] | None :type messages: list[TestMessage] | None
:type summary: str | None :type summary: unicode | None
""" """
super(TestFailure, self).__init__(command, test, python_version) super(TestFailure, self).__init__(command, test, python_version)

@ -5,7 +5,7 @@ minversion = 2.5.0
[testenv] [testenv]
changedir = {toxinidir}/../../ changedir = {toxinidir}/../../
commands = {posargs} commands = {posargs}
passenv = HOME SHIPPABLE* passenv = HOME LC_ALL SHIPPABLE*
args_are_paths = False args_are_paths = False
deps = setuptools == 35.0.2 deps = setuptools == 35.0.2
wheel < 0.30.0 ; python_version < '2.7' wheel < 0.30.0 ; python_version < '2.7'

@ -18,6 +18,7 @@ cell-var-from-loop
consider-iterating-dictionary consider-iterating-dictionary
consider-using-enumerate consider-using-enumerate
dangerous-default-value dangerous-default-value
deprecated-lambda
deprecated-method deprecated-method
deprecated-module deprecated-module
duplicate-key duplicate-key
@ -32,6 +33,7 @@ global-variable-not-assigned
global-variable-undefined global-variable-undefined
import-error import-error
import-self import-self
invalid-encoded-data
invalid-name invalid-name
line-too-long line-too-long
locally-disabled locally-disabled
@ -41,6 +43,7 @@ lost-exception
method-hidden method-hidden
misplaced-comparison-constant misplaced-comparison-constant
missing-docstring missing-docstring
no-init
no-member no-member
no-name-in-module no-name-in-module
no-self-use no-self-use
@ -49,6 +52,7 @@ non-iterator-returned
not-a-mapping not-a-mapping
not-an-iterable not-an-iterable
not-callable not-callable
old-style-class
pointless-statement pointless-statement
pointless-string-statement pointless-string-statement
protected-access protected-access
@ -58,6 +62,7 @@ redefined-outer-name
redefined-variable-type redefined-variable-type
redundant-unittest-assert redundant-unittest-assert
reimported reimported
relative-import
signature-differs signature-differs
simplifiable-if-statement simplifiable-if-statement
super-init-not-called super-init-not-called

Loading…
Cancel
Save