fixup: correct rebase mistakes, to be squashed
This commit is contained in:
parent
dfde2c6c34
commit
02ad46a5a4
|
@ -94,21 +94,15 @@ 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
|
|
||||||
def CodeLocation__str__(self: CodeLocation) -> str:
|
|
||||||
"""Python 3.6.0 hack for NamedTuple __str__"""
|
"""Python 3.6.0 hack for NamedTuple __str__"""
|
||||||
return f"{self.path}:{self.lineno}"
|
return f"{self.path}:{self.lineno}"
|
||||||
|
|
||||||
|
|
||||||
setattr(CodeLocation, "__str__", CodeLocation__str__)
|
|
||||||
|
|
||||||
|
|
||||||
def getlocation(
|
def getlocation(
|
||||||
function, *, relative_to: Path | None, allow_escape: bool
|
function, *, relative_to: Path | None, allow_escape: bool
|
||||||
) -> CodeLocation:
|
) -> CodeLocation:
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue