Skip to content

Commit b64e0a7

Browse files
committed
Using functools to wrap QTest methods
1 parent 7e2650e commit b64e0a7

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

pytestqt/plugin.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from contextlib import contextmanager
2+
import functools
23
import sys
34
import traceback
45

@@ -15,15 +16,16 @@ def _inject_qtest_methods(cls):
1516

1617
def create_qtest_proxy_method(method_name):
1718

19+
qtest_method = getattr(QtTest.QTest, method_name)
20+
1821
def result(*args, **kwargs):
19-
m = getattr(QtTest.QTest, method_name)
20-
return m(*args, **kwargs)
22+
return qtest_method(*args, **kwargs)
2123

22-
result.__name__ = method_name
24+
functools.update_wrapper(result, qtest_method)
2325
return staticmethod(result)
2426

2527
# inject methods from QTest into QtBot
26-
method_names = set([
28+
method_names = [
2729
'keyPress',
2830
'keyClick',
2931
'keyClicks',
@@ -38,7 +40,7 @@ def result(*args, **kwargs):
3840
'mouseMove',
3941
'mousePress',
4042
'mouseRelease',
41-
])
43+
]
4244
for method_name in method_names:
4345
method = create_qtest_proxy_method(method_name)
4446
setattr(cls, method_name, method)
@@ -202,7 +204,7 @@ def stopForInteraction(self):
202204
Closing the windows should resume the test run, with ``qtbot`` attempting to restore visibility
203205
of the widgets as they were before this call.
204206
205-
.. note:: As a convenience, it is aliased as `stop`.
207+
.. note:: As a convenience, it is also aliased as `stop`.
206208
"""
207209
widget_visibility = [widget.isVisible() for widget in self._widgets]
208210

0 commit comments

Comments
 (0)