1
1
from contextlib import contextmanager
2
+ import functools
2
3
import sys
3
4
import traceback
4
5
@@ -15,15 +16,16 @@ def _inject_qtest_methods(cls):
15
16
16
17
def create_qtest_proxy_method (method_name ):
17
18
19
+ qtest_method = getattr (QtTest .QTest , method_name )
20
+
18
21
def result (* args , ** kwargs ):
19
- m = getattr (QtTest .QTest , method_name )
20
- return m (* args , ** kwargs )
22
+ return qtest_method (* args , ** kwargs )
21
23
22
- result . __name__ = method_name
24
+ functools . update_wrapper ( result , qtest_method )
23
25
return staticmethod (result )
24
26
25
27
# inject methods from QTest into QtBot
26
- method_names = set ( [
28
+ method_names = [
27
29
'keyPress' ,
28
30
'keyClick' ,
29
31
'keyClicks' ,
@@ -38,7 +40,7 @@ def result(*args, **kwargs):
38
40
'mouseMove' ,
39
41
'mousePress' ,
40
42
'mouseRelease' ,
41
- ])
43
+ ]
42
44
for method_name in method_names :
43
45
method = create_qtest_proxy_method (method_name )
44
46
setattr (cls , method_name , method )
@@ -202,7 +204,7 @@ def stopForInteraction(self):
202
204
Closing the windows should resume the test run, with ``qtbot`` attempting to restore visibility
203
205
of the widgets as they were before this call.
204
206
205
- .. note:: As a convenience, it is aliased as `stop`.
207
+ .. note:: As a convenience, it is also aliased as `stop`.
206
208
"""
207
209
widget_visibility = [widget .isVisible () for widget in self ._widgets ]
208
210
0 commit comments