PyCollector.collect: use explicit cast to `str`

Ref: https://github.com/pytest-dev/pytest/pull/6521#pullrequestreview-347234792
This commit is contained in:
Ran Benita 2020-01-23 12:54:52 +01:00 committed by Daniel Hahler
parent 9c7b3c57d7
commit 0b6258ab5b
1 changed files with 6 additions and 1 deletions

View File

@ -369,7 +369,12 @@ class PyCollector(PyobjMixin, nodes.Collector):
if not isinstance(res, list):
res = [res]
values.extend(res)
values.sort(key=lambda item: item.reportinfo()[:2])
def sort_key(item):
fspath, lineno, _ = item.reportinfo()
return (str(fspath), lineno)
values.sort(key=sort_key)
return values
def _makeitem(self, name, obj):