From a4cf5ca07ec914417ab5e9e44596d466c6886421 Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Wed, 8 Apr 2020 14:13:48 -0700 Subject: [PATCH] tox: Don't inline python warnings The sphinx regex is picking up python warnings. We can disambiguate the two because sphinx doesn't emit a space before the message but the python warnings module does. This adjusts the regex to do that and adds a test file that includes warnings output. If we need/want to make this more robust, we could also simply filter the sphinx output for messages that start with " ?\w+Warning:". We could also decide that we want to include python warnings. Change-Id: Ib58cc1a2d4f673a0ce3d2a9cae306004559f5b52 --- roles/tox/library/test-cases/warning_output.yaml | 10 ++++++++++ roles/tox/library/tox_parse_output.py | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 roles/tox/library/test-cases/warning_output.yaml diff --git a/roles/tox/library/test-cases/warning_output.yaml b/roles/tox/library/test-cases/warning_output.yaml new file mode 100644 index 000000000..4d0cebd94 --- /dev/null +++ b/roles/tox/library/test-cases/warning_output.yaml @@ -0,0 +1,10 @@ +--- +workdir: . +output: | + tests/test_discovery.py:25: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details. + config = yaml.load(open('hiera/common.yaml', 'r')) + tests/test_discovery.py:714: UserWarning: Policy "foo:create_bar":"role:fizz" was deprecated in N in favor of "foo:create_bar":"". Reason: because of reasons. Either ensure your deployment is ready for the new default or copy/paste the deprecated policy into your policy file and maintain it manually. + warnings.warn(deprecated_msg) + WARNING [oslo_policy.policy] Policies ['foo', 'bar'] are part of a cyclical reference. + WARNING [oslo_policy.policy] Policies ['foo', 'bar'] are part of a cyclical reference. +comments: {} diff --git a/roles/tox/library/tox_parse_output.py b/roles/tox/library/tox_parse_output.py index b2532ac90..3a6d77c44 100644 --- a/roles/tox/library/tox_parse_output.py +++ b/roles/tox/library/tox_parse_output.py @@ -42,7 +42,7 @@ from ansible.module_utils.basic import AnsibleModule ANSI_RE = re.compile(r'(?:\x1B[@-_]|[\x80-\x9F])[0-?]*[ -/]*[@-~]') PEP8_RE = re.compile(r"^(.*):(\d+):(\d+): (.*)$") -SPHINX_RE = re.compile(r"^([^:]*):([\d]+):(.+)$") +SPHINX_RE = re.compile(r"^([^:]*):([\d]+):(\w.+)$") def simple_matcher(line, regex, file_path_group, start_line_group,