config: let main() accept any os.PathLike instead of just py.path.local
Really it ought to only take the List[str], but for backward compatibility, at least get rid of the explicit py.path.local check.
This commit is contained in:
parent
73586be08f
commit
2c05a7babb
|
@ -128,7 +128,7 @@ def filter_traceback_for_conftest_import_failure(
|
|||
|
||||
|
||||
def main(
|
||||
args: Optional[Union[List[str], py.path.local]] = None,
|
||||
args: Optional[Union[List[str], "os.PathLike[str]"]] = None,
|
||||
plugins: Optional[Sequence[Union[str, _PluggyPlugin]]] = None,
|
||||
) -> Union[int, ExitCode]:
|
||||
"""Perform an in-process test run.
|
||||
|
@ -295,13 +295,15 @@ def get_plugin_manager() -> "PytestPluginManager":
|
|||
|
||||
|
||||
def _prepareconfig(
|
||||
args: Optional[Union[py.path.local, List[str]]] = None,
|
||||
args: Optional[Union[List[str], "os.PathLike[str]"]] = None,
|
||||
plugins: Optional[Sequence[Union[str, _PluggyPlugin]]] = None,
|
||||
) -> "Config":
|
||||
if args is None:
|
||||
args = sys.argv[1:]
|
||||
elif isinstance(args, py.path.local):
|
||||
args = [str(args)]
|
||||
# TODO: Remove type-ignore after next mypy release.
|
||||
# https://github.com/python/typeshed/commit/076983eec45e739c68551cb6119fd7d85fd4afa9
|
||||
elif isinstance(args, os.PathLike): # type: ignore[misc]
|
||||
args = [os.fspath(args)]
|
||||
elif not isinstance(args, list):
|
||||
msg = "`args` parameter expected to be a list of strings, got: {!r} (type: {})"
|
||||
raise TypeError(msg.format(args, type(args)))
|
||||
|
|
|
@ -277,7 +277,7 @@ class TestCollectPluginHookRelay:
|
|||
wascalled.append(path)
|
||||
|
||||
pytester.makefile(".abc", "xyz")
|
||||
pytest.main(py.path.local(pytester.path), plugins=[Plugin()])
|
||||
pytest.main(pytester.path, plugins=[Plugin()])
|
||||
assert len(wascalled) == 1
|
||||
assert wascalled[0].ext == ".abc"
|
||||
|
||||
|
|
Loading…
Reference in New Issue