@@ -70,19 +70,11 @@ class NodeMeta(type):
70
70
__in_named_ctor = False
71
71
72
72
def __call__ (self , * k , ** kw ):
73
- if not self .__in_named_ctor :
74
- warnings .warn (NODE_USE_FROM_PARENT .format (name = self .__name__ ), stacklevel = 3 )
75
- return self ._create (* k , ** kw )
76
-
77
- @contextmanager
78
- def __ctor_entered (self ):
79
- self .__in_named_ctor = True
80
- yield
81
- self .__in_named_ctor = False
73
+ warnings .warn (NODE_USE_FROM_PARENT .format (name = self .__name__ ), stacklevel = 3 )
74
+ return super ().__call__ (* k , ** kw )
82
75
83
76
def _create (self , * k , ** kw ):
84
- with self .__ctor_entered ():
85
- return super ().__call__ (* k , ** kw )
77
+ return super ().__call__ (* k , ** kw )
86
78
87
79
88
80
class Node (metaclass = NodeMeta ):
@@ -128,8 +120,8 @@ def __init__(
128
120
self ._nodeid += "::" + self .name
129
121
130
122
@classmethod
131
- def from_parent (cls , parent , ** kw ):
132
- return cls ._create (** kw , parent = parent )
123
+ def from_parent (cls , parent , * , name ):
124
+ return cls ._create (parent = parent , name = name )
133
125
134
126
@property
135
127
def ihook (self ):
@@ -411,6 +403,10 @@ def __init__(self, fspath, parent=None, config=None, session=None, nodeid=None):
411
403
412
404
super ().__init__ (name , parent , config , session , nodeid = nodeid , fspath = fspath )
413
405
406
+ @classmethod
407
+ def from_parent (cls , parent , * , fspath ):
408
+ return cls ._create (parent = parent , fspath = fspath )
409
+
414
410
415
411
class File (FSCollector ):
416
412
""" base class for collecting tests from a file. """
0 commit comments