fixup: correct rebase mistakes, to be squashed

This commit is contained in:
Ronny Pfannschmidt 2023-03-17 09:58:27 +01:00
parent dfde2c6c34
commit 02ad46a5a4
2 changed files with 5 additions and 11 deletions

View File

@ -94,19 +94,13 @@ def is_async_function(func: object) -> bool:
return iscoroutinefunction(func) or inspect.isasyncgenfunction(func) return iscoroutinefunction(func) or inspect.isasyncgenfunction(func)
def getlocation(function, curdir: str | None = None) -> str:
class CodeLocation(NamedTuple): class CodeLocation(NamedTuple):
path: Path path: Path
lineno: int lineno: int
def __str__(self: CodeLocation) -> str:
# TODO: integrate after pytest 3.6.0 has been dropped """Python 3.6.0 hack for NamedTuple __str__"""
def CodeLocation__str__(self: CodeLocation) -> str: return f"{self.path}:{self.lineno}"
"""Python 3.6.0 hack for NamedTuple __str__"""
return f"{self.path}:{self.lineno}"
setattr(CodeLocation, "__str__", CodeLocation__str__)
def getlocation( def getlocation(

View File

@ -1554,7 +1554,7 @@ def _ascii_escaped_by_config(val: Union[str, bytes], config: Optional[Config]) -
def _pretty_fixture_path(func) -> str: def _pretty_fixture_path(func) -> str:
cwd = Path.cwd() cwd = Path.cwd()
loc = Path(getlocation(func, str(cwd))) loc = Path(str(getlocation(func, relative_to=cwd, allow_escape=False)))
prefix = Path("...", "_pytest") prefix = Path("...", "_pytest")
try: try:
return str(prefix / loc.relative_to(_PYTEST_DIR)) return str(prefix / loc.relative_to(_PYTEST_DIR))
@ -1577,7 +1577,7 @@ def _show_fixtures_per_test(config: Config, session: Session) -> None:
verbose = config.getvalue("verbose") verbose = config.getvalue("verbose")
def get_best_relpath(func): def get_best_relpath(func):
return getlocation(func, curdir) return getlocation(func, relative_to=curdir, allow_escape=False)
def write_fixture(fixture_def: fixtures.FixtureDef[object]) -> None: def write_fixture(fixture_def: fixtures.FixtureDef[object]) -> None:
argname = fixture_def.argname argname = fixture_def.argname