Skip to content
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

JUnit XML output: Include timezone information in XML #33

Merged
merged 5 commits into from Sep 8, 2020

Conversation

wmanley
Copy link
Contributor

@wmanley wmanley commented Sep 4, 2020

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 incompatibility caused by this change. If you
experience this please get in contact at support@stb-tester.com.

TODO:

  • Test against real portal
  • Test with real Jenkins

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.
@wmanley
Copy link
Contributor Author

wmanley commented Sep 4, 2020

Hmm, CI failed with:

AttributeError: module 'isort' has no attribute 'SortImports'

Looks like a version locking issue.

…8.04

To fix "AttributeError: module 'isort' has no attribute 'SortImports'".
@drothlis
Copy link
Contributor

drothlis commented Sep 7, 2020

Well, it looks like AppVeyor has caught an incompatibility with new versions of pytest:
https://ci.appveyor.com/project/drothlis/stbt-rig/builds/35072163/job/atimtgkwgppxebqj

________________________ ERROR collecting test session ________________________
c:\python36-x64\lib\site-packages\pluggy\hooks.py:286: in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
c:\python36-x64\lib\site-packages\pluggy\manager.py:93: in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
c:\python36-x64\lib\site-packages\pluggy\manager.py:87: in <lambda>
    firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
C:\projects\stbt-rig\stbt_rig.py:1227: in pytest_collect_file
    return StbtCollector(path, parent)
c:\python36-x64\lib\site-packages\_pytest\nodes.py:95: in __call__
    warnings.warn(NODE_USE_FROM_PARENT.format(name=self.__name__), stacklevel=2)
E   pytest.PytestDeprecationWarning: Direct construction of StbtCollector has been deprecated, please use StbtCollector.from_parent.
E   See https://docs.pytest.org/en/stable/deprecations.html#node-construction-changed-to-node-from-parent for more details.

I'm going to stop working on this now so back over to you @wmanley.

@wmanley
Copy link
Contributor Author

wmanley commented Sep 8, 2020

Reproduced locally with:

$ python3 -m venv new-pytest
$ source new-pytest/bin/activate
$ pip install -r requirements.txt
...
$ pytest --version
pytest 6.0.1
$ pytest *.py
...

@wmanley
Copy link
Contributor Author

wmanley commented Sep 8, 2020

Now there are only pylint issues remaining:

************* 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

This is a curious one. I think the get_closest_marker issue is casued by a limitation of pylint caused by a curious pattern in pytest.

Source:

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)

So it's repeated in the function definition. The last definition will take precedence. Not sure why they've done this.

@wmanley
Copy link
Contributor Author

wmanley commented Sep 8, 2020

Regarding gethookproxy and isinitpath, the same issue is reported here: pytest-dev/pytest#7591 and will be fixed in 6.1: pytest-dev/pytest#7648.

I guess I'll just have to disable this lint :(

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:
pytest-dev/pytest#7591 .  This is fixed in
pytest 6.1: pytest-dev/pytest#7648
@drothlis drothlis merged commit b6c717b into master Sep 8, 2020
@drothlis drothlis deleted the junit-timestamp-tz branch September 8, 2020 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants