@@ -1190,7 +1190,9 @@ def parseconfigure(self, *args: Union[str, "os.PathLike[str]"]) -> Config:
1190
1190
config ._do_configure ()
1191
1191
return config
1192
1192
1193
- def getitem (self , source : str , funcname : str = "test_func" ) -> Item :
1193
+ def getitem (
1194
+ self , source : Union [str , "os.PathLike[str]" ], funcname : str = "test_func"
1195
+ ) -> Item :
1194
1196
"""Return the test item for a test function.
1195
1197
1196
1198
Writes the source to a python file and runs pytest's collection on
@@ -1210,7 +1212,7 @@ def getitem(self, source: str, funcname: str = "test_func") -> Item:
1210
1212
funcname , source , items
1211
1213
)
1212
1214
1213
- def getitems (self , source : str ) -> List [Item ]:
1215
+ def getitems (self , source : Union [ str , "os.PathLike[str]" ] ) -> List [Item ]:
1214
1216
"""Return all test items collected from the module.
1215
1217
1216
1218
Writes the source to a Python file and runs pytest's collection on
@@ -1220,7 +1222,11 @@ def getitems(self, source: str) -> List[Item]:
1220
1222
return self .genitems ([modcol ])
1221
1223
1222
1224
def getmodulecol (
1223
- self , source : Union [str , Path ], configargs = (), * , withinit : bool = False
1225
+ self ,
1226
+ source : Union [str , "os.PathLike[str]" ],
1227
+ configargs = (),
1228
+ * ,
1229
+ withinit : bool = False ,
1224
1230
):
1225
1231
"""Return the module collection node for ``source``.
1226
1232
@@ -1238,7 +1244,9 @@ def getmodulecol(
1238
1244
Whether to also write an ``__init__.py`` file to the same
1239
1245
directory to ensure it is a package.
1240
1246
"""
1241
- if isinstance (source , Path ):
1247
+ # TODO: Remove type ignore in next mypy release (> 0.790).
1248
+ # https://github.com/python/typeshed/pull/4582
1249
+ if isinstance (source , os .PathLike ): # type: ignore[misc]
1242
1250
path = self .path .joinpath (source )
1243
1251
assert not withinit , "not supported for paths"
1244
1252
else :
0 commit comments