@pytest.fixture
def fake_keyevent_factory():
 def fake_keyevent(key, modifiers=0, text='', typ=QEvent.KeyPress):
  'Generate a new fake QKeyPressEvent.'
  evtmock = unittest.mock.create_autospec(QKeyEvent, instance=True)
  evtmock.key.return_value = key
  evtmock.modifiers.return_value = modifiers
  evtmock.text.return_value = text
  evtmock.type.return_value = typ
  return evtmock
 return fake_keyevent

@ pytest . fixture def fake_keyevent_factory ( ) : def fake_keyevent ( key , modifiers = 0 , text = '' , typ = QEvent . KeyPress ) : evtmock = unittest . mock . create_autospec ( QKeyEvent , instance = True ) evtmock . key . return_value = key evtmock . modifiers . return_value = modifiers evtmock . text . return_value = text evtmock . type . return_value = typ return evtmock return fake_keyevent
fixture that when called will return a mock instance of a qkeyevent .