From 9b013319343d28d0d4eac503ad0b41ace8ab4c0c Mon Sep 17 00:00:00 2001 From: William Manley Date: Fri, 4 Sep 2020 16:41:34 +0100 Subject: [PATCH 1/5] JUnit XML output: Include timezone information in XML JUnit writes local-time without a timezone by default. This means that JUnit XML parsers default to local-time. The portal doesn't know what timezone the user of stbt-rig wants so these timestamps can be interpreted incorrectly. This change includes timezone information in the XML output. There is a small chance of incompatibilty caused by this change. If you experience this please get in contact at support@stb-tester.com. --- stbt_rig.py | 3 ++- test_stbt_rig.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/stbt_rig.py b/stbt_rig.py index 00e2e9a..f8f73ca 100755 --- a/stbt_rig.py +++ b/stbt_rig.py @@ -839,7 +839,8 @@ def list_results(self): def list_results_xml(self): r = self.portal._get( - '/api/v2/results.xml', params={'filter': 'job:%s' % self.job_uid}) + '/api/v2/results.xml', params={'filter': 'job:%s' % self.job_uid, + 'include_tz': 'true'}) r.raise_for_status() return r.text diff --git a/test_stbt_rig.py b/test_stbt_rig.py index 253a01f..aca72b7 100644 --- a/test_stbt_rig.py +++ b/test_stbt_rig.py @@ -208,6 +208,7 @@ def get_results(): @self.app.route('/api/v2/results.xml') def get_results_xml(): assert flask.request.args['filter'] == 'job:/mynode/6Pfq/167' + assert flask.request.args['include_tz'] == 'true' return PortalMock.RESULTS_XML @self.app.route('/api/v2/results/') @@ -276,7 +277,7 @@ def on_run_tests(self, j): RESULTS_XML = ( '' + 'timestamp="2019-06-12T15:26:35+00:00">' '' '') From 157bf6151fefbef5e9eb2ff90019e5582d0af8f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20R=C3=B6thlisberger?= Date: Mon, 7 Sep 2020 17:33:30 +0100 Subject: [PATCH 2/5] requirements.txt: Set pylint/astroid/isort versions to match Ubuntu 18.04 To fix "AttributeError: module 'isort' has no attribute 'SortImports'". --- requirements.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 3991995..ee33381 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,8 +5,9 @@ requests # Dependencies of the tests requests-mock -pylint==1.9.3 -astroid==1.6.5 +pylint==1.8.3 +astroid==1.6.0 flask==1.1.1 +isort==4.3.4 subprocess32==3.5.4 ; python_version=='2.7' werkzeug==0.15.5 From 7e72a348edeb8987a7f31a17cd4f2b06a83421dc Mon Sep 17 00:00:00 2001 From: William Manley Date: Tue, 8 Sep 2020 12:51:10 +0100 Subject: [PATCH 3/5] pytest: Fix deprecation warning when running against pytest 5.4 See https://docs.pytest.org/en/stable/deprecations.html#node-construction-changed-to-node-from-parent --- stbt_rig.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/stbt_rig.py b/stbt_rig.py index f8f73ca..2f8144b 100755 --- a/stbt_rig.py +++ b/stbt_rig.py @@ -1223,7 +1223,13 @@ def pytest_addoption(parser): def pytest_collect_file(path, parent): if path.ext == ".py": - return StbtCollector(path, parent) + if hasattr(StbtCollector, "from_parent"): + # pytest >v5.4 + return StbtCollector.from_parent(parent=parent, fspath=path) # pylint:disable=no-member + else: + # Backwards compat + # https://docs.pytest.org/en/stable/deprecations.html#node-construction-changed-to-node-from-parent + return StbtCollector(path, parent) else: return None @@ -1235,7 +1241,17 @@ def collect(self): for n, line in enumerate(f): m = re.match(r'^def\s+(test_[a-zA-Z0-9_]*)', line) if m: - yield StbtRemoteTest(self, self.name, m.group(1), n + 1) + if hasattr(StbtRemoteTest, "from_parent"): + # pytest >v5.4 + srt = StbtRemoteTest.from_parent( # pylint:disable=no-member + parent=self, filename=self.name, + testname=m.group(1), line_number=n + 1) + else: + # Backwards compat + # https://docs.pytest.org/en/stable/deprecations.html#node-construction-changed-to-node-from-parent + srt = StbtRemoteTest( + self, self.name, m.group(1), n + 1) + yield srt class StbtRemoteTest(pytest.Item): From 08284a5f40025f4abee195a0054365aabad81a65 Mon Sep 17 00:00:00 2001 From: William Manley Date: Tue, 8 Sep 2020 14:38:33 +0100 Subject: [PATCH 4/5] Disable irrelevant pylint errors Errors were: ``` ************* Module stbt_rig stbt_rig.py:1237:4: [W0223(abstract-method), StbtCollector] Method 'get_closest_marker' is abstract in class 'Node' but is not overridden stbt_rig.py:1237:4: [W0223(abstract-method), StbtCollector] Method 'gethookproxy' is abstract in class 'FSCollector' but is not overridden stbt_rig.py:1237:4: [W0223(abstract-method), StbtCollector] Method 'isinitpath' is abstract in class 'FSCollector' but is not overridden stbt_rig.py:1257:4: [W0223(abstract-method), StbtRemoteTest] Method 'get_closest_marker' is abstract in class 'Node' but is not overridden ``` The `get_closest_marker` is a pylint false positive because it's defined multiple times in `class Node`: ```python class Node(metaclass=NodeMeta): ... @overload def get_closest_marker(self, name: str) -> Optional[Mark]: raise NotImplementedError() @overload # noqa: F811 def get_closest_marker(self, name: str, default: Mark) -> Mark: # noqa: F811 raise NotImplementedError() def get_closest_marker( # noqa: F811 self, name: str, default: Optional[Mark] = None ) -> Optional[Mark]: """return the first marker matching the name, from closest (for example function) to farther level (for example module level). :param default: fallback return value of no marker was found :param name: name to filter by """ return next(self.iter_markers(name=name), default) ``` The other two don't need to be inherited because they'll never be called: https://github.com/pytest-dev/pytest/issues/7591 . This is fixed in pytest 6.1: https://github.com/pytest-dev/pytest/pull/7648 --- stbt_rig.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/stbt_rig.py b/stbt_rig.py index 2f8144b..131d668 100755 --- a/stbt_rig.py +++ b/stbt_rig.py @@ -1235,6 +1235,7 @@ def pytest_collect_file(path, parent): class StbtCollector(pytest.File): + # pylint: disable=abstract-method def collect(self): with open(self.fspath.strpath) as f: # We implement our own parsing to avoid import stbt ImportErrors @@ -1255,6 +1256,7 @@ def collect(self): class StbtRemoteTest(pytest.Item): + # pylint: disable=abstract-method def __init__(self, parent, filename, testname, line_number): super(StbtRemoteTest, self).__init__(testname, parent) self._filename = filename From f2a02dd078c052f429ae27b11f0f01a501904d3e Mon Sep 17 00:00:00 2001 From: William Manley Date: Tue, 8 Sep 2020 16:53:23 +0100 Subject: [PATCH 5/5] Update Copyright notice year --- stbt_rig.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stbt_rig.py b/stbt_rig.py index 131d668..1188ee3 100755 --- a/stbt_rig.py +++ b/stbt_rig.py @@ -6,7 +6,7 @@ For more details, and to get the latest version of this script, see . -Copyright 2017-2019 Stb-tester.com Ltd. +Copyright 2017-2020 Stb-tester.com Ltd. Released under the MIT license. """