Skip to content

Commit 02ad46a

Browse files
fixup: correct rebase mistakes, to be squashed
1 parent dfde2c6 commit 02ad46a

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

src/_pytest/compat.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,19 +94,13 @@ def is_async_function(func: object) -> bool:
9494
return iscoroutinefunction(func) or inspect.isasyncgenfunction(func)
9595

9696

97-
def getlocation(function, curdir: str | None = None) -> str:
9897
class CodeLocation(NamedTuple):
9998
path: Path
10099
lineno: int
101100

102-
103-
# TODO: integrate after pytest 3.6.0 has been dropped
104-
def CodeLocation__str__(self: CodeLocation) -> str:
105-
"""Python 3.6.0 hack for NamedTuple __str__"""
106-
return f"{self.path}:{self.lineno}"
107-
108-
109-
setattr(CodeLocation, "__str__", CodeLocation__str__)
101+
def __str__(self: CodeLocation) -> str:
102+
"""Python 3.6.0 hack for NamedTuple __str__"""
103+
return f"{self.path}:{self.lineno}"
110104

111105

112106
def getlocation(

src/_pytest/python.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1554,7 +1554,7 @@ def _ascii_escaped_by_config(val: Union[str, bytes], config: Optional[Config]) -
15541554

15551555
def _pretty_fixture_path(func) -> str:
15561556
cwd = Path.cwd()
1557-
loc = Path(getlocation(func, str(cwd)))
1557+
loc = Path(str(getlocation(func, relative_to=cwd, allow_escape=False)))
15581558
prefix = Path("...", "_pytest")
15591559
try:
15601560
return str(prefix / loc.relative_to(_PYTEST_DIR))
@@ -1577,7 +1577,7 @@ def _show_fixtures_per_test(config: Config, session: Session) -> None:
15771577
verbose = config.getvalue("verbose")
15781578

15791579
def get_best_relpath(func):
1580-
return getlocation(func, curdir)
1580+
return getlocation(func, relative_to=curdir, allow_escape=False)
15811581

15821582
def write_fixture(fixture_def: fixtures.FixtureDef[object]) -> None:
15831583
argname = fixture_def.argname

0 commit comments

Comments
 (0)