@@ -151,6 +151,23 @@ def __init__(
151151 self .source = source or DATA_DIR
152152 self .root = root .resolve ()
153153
154+ def find (self , identifier : str ) -> pathlib .Path :
155+ """Convenience method for finding a data file."""
156+ path = pathlib .Path (identifier )
157+ if path .parent == pathlib .Path ("." ):
158+ # No group provided but it's a distribution file, assume it's from packages/
159+ if path .name .endswith ((".whl" , ".tar.gz" )):
160+ group = "packages"
161+ else :
162+ raise ValueError ("must provide a data group prefix" )
163+ else :
164+ group = path .parent .name
165+
166+ resource = self .root / group / path .name
167+ if not resource .exists ():
168+ raise ValueError (f"data '{ identifier } ' does not exist!" )
169+ return resource
170+
154171 @classmethod
155172 def copy (cls , root : pathlib .Path ) -> TestData :
156173 obj = cls (root )
@@ -725,13 +742,24 @@ def pip(
725742 def pip_install_local (
726743 self ,
727744 * args : StrPath ,
745+ find_links : StrPath | list [StrPath ] = "packages" ,
728746 ** kwargs : Any ,
729747 ) -> TestPipResult :
748+ if not isinstance (find_links , list ):
749+ find_links = [find_links ]
750+ find_links_args : list [StrPath ] = []
751+ for folder in find_links :
752+ path = pathlib .Path (folder )
753+ find_links_args .append ("--find-links" )
754+ if path .parent == pathlib .Path ("." ):
755+ find_links_args .append (pathlib .Path (DATA_DIR , folder ).as_uri ())
756+ else :
757+ find_links_args .append (path )
758+
730759 return self .pip (
731760 "install" ,
732761 "--no-index" ,
733- "--find-links" ,
734- pathlib .Path (DATA_DIR , "packages" ).as_uri (),
762+ * find_links_args ,
735763 * args ,
736764 ** kwargs ,
737765 )
0 commit comments