Merge pull request #9184 from bluetech/reportinfo-pathlike

[7.0] Change `Node.reportinfo()` return value from `py.path` to `str|os.PathLike[str]`
This commit is contained in:
Ran Benita
2021-10-11 14:33:03 +03:00
committed by GitHub
8 changed files with 28 additions and 27 deletions

View File

@@ -1154,8 +1154,8 @@ class TestReportInfo:
def test_func_reportinfo(self, pytester: Pytester) -> None:
item = pytester.getitem("def test_func(): pass")
fspath, lineno, modpath = item.reportinfo()
assert str(fspath) == str(item.path)
path, lineno, modpath = item.reportinfo()
assert os.fspath(path) == str(item.path)
assert lineno == 0
assert modpath == "test_func"
@@ -1169,8 +1169,8 @@ class TestReportInfo:
)
classcol = pytester.collect_by_name(modcol, "TestClass")
assert isinstance(classcol, Class)
fspath, lineno, msg = classcol.reportinfo()
assert str(fspath) == str(modcol.path)
path, lineno, msg = classcol.reportinfo()
assert os.fspath(path) == str(modcol.path)
assert lineno == 1
assert msg == "TestClass"
@@ -1194,7 +1194,7 @@ class TestReportInfo:
assert isinstance(classcol, Class)
instance = list(classcol.collect())[0]
assert isinstance(instance, Instance)
fspath, lineno, msg = instance.reportinfo()
path, lineno, msg = instance.reportinfo()
def test_customized_python_discovery(pytester: Pytester) -> None:

View File

@@ -19,7 +19,7 @@ class TestOEJSKITSpecials:
return MyCollector.from_parent(collector, name=name)
class MyCollector(pytest.Collector):
def reportinfo(self):
return self.fspath, 3, "xyz"
return self.path, 3, "xyz"
"""
)
modcol = pytester.getmodulecol(
@@ -52,7 +52,7 @@ class TestOEJSKITSpecials:
return MyCollector.from_parent(collector, name=name)
class MyCollector(pytest.Collector):
def reportinfo(self):
return self.fspath, 3, "xyz"
return self.path, 3, "xyz"
"""
)
modcol = pytester.getmodulecol(