File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ def register(self, func):
64
64
)
65
65
)
66
66
self ._registry [func .__name__ ] = wraps (func )(FuncWrapper (func ))
67
- return self
67
+ return func
68
68
69
69
def __getattribute__ (self , name ):
70
70
if name in ('__class__' , '_registry' , 'register' ):
Original file line number Diff line number Diff line change @@ -191,3 +191,28 @@ def test_helpers():
191
191
192
192
# make sure that that we get a '0' exit code for the testsuite
193
193
assert result .ret != 0
194
+
195
+
196
+ def test_helper_as_regular_function (testdir ):
197
+ testdir .makepyfile ('''
198
+ import pytest
199
+
200
+ @pytest.helpers.register
201
+ def foo():
202
+ return 'bar'
203
+
204
+ def test_helpers():
205
+ assert pytest.helpers.foo() == 'bar'
206
+ assert foo() == 'bar'
207
+ print('PASSED')
208
+ ''' )
209
+
210
+ result = testdir .runpytest ('-s' )
211
+
212
+ # fnmatch_lines does an assertion internally
213
+ result .stdout .fnmatch_lines ([
214
+ 'test_helper_as_regular_function.py PASSED' ,
215
+ ])
216
+
217
+ # make sure that that we get a '0' exit code for the testsuite
218
+ assert result .ret == 0
You can’t perform that action at this time.
0 commit comments