@@ -213,8 +213,8 @@ def path_matches_patterns(path, patterns):
213213
214214def pytest_pycollect_makemodule (path , parent ):
215215 if path .basename == "__init__.py" :
216- return Package . from_parent ( parent , fspath = path )
217- return Module . from_parent ( parent , fspath = path )
216+ return Package ( path , parent )
217+ return Module ( path , parent )
218218
219219
220220@hookimpl (hookwrapper = True )
@@ -226,7 +226,7 @@ def pytest_pycollect_makeitem(collector, name, obj):
226226 # nothing was collected elsewhere, let's do it here
227227 if safe_isclass (obj ):
228228 if collector .istestclass (obj , name ):
229- outcome .force_result (Class . from_parent ( collector , name = name , obj = obj ))
229+ outcome .force_result (Class ( name , parent = collector ))
230230 elif collector .istestfunction (obj , name ):
231231 # mock seems to store unbound methods (issue473), normalize it
232232 obj = getattr (obj , "__func__" , obj )
@@ -245,7 +245,7 @@ def pytest_pycollect_makeitem(collector, name, obj):
245245 )
246246 elif getattr (obj , "__test__" , True ):
247247 if is_generator (obj ):
248- res = Function . from_parent ( collector , name = name )
248+ res = Function ( name , parent = collector )
249249 reason = "yield tests were removed in pytest 4.0 - {name} will be ignored" .format (
250250 name = name
251251 )
@@ -415,7 +415,7 @@ def _genfunctions(self, name, funcobj):
415415 cls = clscol and clscol .obj or None
416416 fm = self .session ._fixturemanager
417417
418- definition = FunctionDefinition . from_parent ( self , name = name , callobj = funcobj )
418+ definition = FunctionDefinition ( name = name , parent = self , callobj = funcobj )
419419 fixtureinfo = definition ._fixtureinfo
420420
421421 metafunc = Metafunc (
@@ -430,7 +430,7 @@ def _genfunctions(self, name, funcobj):
430430 self .ihook .pytest_generate_tests .call_extra (methods , dict (metafunc = metafunc ))
431431
432432 if not metafunc ._calls :
433- yield Function . from_parent ( self , name = name , fixtureinfo = fixtureinfo )
433+ yield Function ( name , parent = self , fixtureinfo = fixtureinfo )
434434 else :
435435 # add funcargs() as fixturedefs to fixtureinfo.arg2fixturedefs
436436 fixtures .add_funcarg_pseudo_fixture_def (self , metafunc , fm )
@@ -442,9 +442,9 @@ def _genfunctions(self, name, funcobj):
442442
443443 for callspec in metafunc ._calls :
444444 subname = "{}[{}]" .format (name , callspec .id )
445- yield Function .from_parent (
446- self ,
445+ yield Function (
447446 name = subname ,
447+ parent = self ,
448448 callspec = callspec ,
449449 callobj = funcobj ,
450450 fixtureinfo = fixtureinfo ,
@@ -615,7 +615,7 @@ def collect(self):
615615 if init_module .check (file = 1 ) and path_matches_patterns (
616616 init_module , self .config .getini ("python_files" )
617617 ):
618- yield Module . from_parent ( self , fspath = init_module )
618+ yield Module ( init_module , self )
619619 pkg_prefixes = set ()
620620 for path in this_path .visit (rec = self ._recurse , bf = True , sort = True ):
621621 # We will visit our own __init__.py file, in which case we skip it.
@@ -666,13 +666,6 @@ def _get_first_non_fixture_func(obj, names):
666666class Class (PyCollector ):
667667 """ Collector for test methods. """
668668
669- @classmethod
670- def from_parent (cls , parent , * , name , obj = None ):
671- """
672- The public constructor
673- """
674- return super ().from_parent (name = name , parent = parent )
675-
676669 def collect (self ):
677670 if not safe_getattr (self .obj , "__test__" , True ):
678671 return []
@@ -698,7 +691,7 @@ def collect(self):
698691 self ._inject_setup_class_fixture ()
699692 self ._inject_setup_method_fixture ()
700693
701- return [Instance . from_parent ( self , name = "()" )]
694+ return [Instance ( name = "()" , parent = self )]
702695
703696 def _inject_setup_class_fixture (self ):
704697 """Injects a hidden autouse, class scoped fixture into the collected class object
@@ -1456,13 +1449,6 @@ def __init__(
14561449 #: .. versionadded:: 3.0
14571450 self .originalname = originalname
14581451
1459- @classmethod
1460- def from_parent (cls , parent , ** kw ): # todo: determine sound type limitations
1461- """
1462- The public constructor
1463- """
1464- return super ().from_parent (parent = parent , ** kw )
1465-
14661452 def _initrequest (self ):
14671453 self .funcargs = {}
14681454 self ._request = fixtures .FixtureRequest (self )
0 commit comments