pytest-dev / pytest-dev/pytest-qt

Clarification about methods like keyEvent, etc.?

Open
#549 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
455
Forks
72
Avg merge
12h 26m
Merged PRs (30d)
1

Description

First, thanks for this test package, it's a life-saver.

I've been using it for some time now. I just want to simulate pressing of "Enter" on a QLineEdit (for example). There don't seem to be many examples of this kind of thing out there.

In the documentation here we see that something like keyPress or keyEvent is said to be static. (By the way that page appears to list keyPress twice, for no particular reason).

I am currently experimenting with this by going qtbot.keyEvent(...). This appears to work OK. But if that method is static, shouldn't I be using the class instead? If I try qtbot.__class__.keyEvent(...) I get this error:

AttributeError: type object 'MagicMock' has no attribute 'keyEvent'

Also, as a general rule, which should I be using, keyPress or keyEvent? Or doesn't it matter.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the keyPress and keyEvent entries in the linked pytest-qt documentation, including the duplicated keyPress listing. Clarify whether these methods are static, how they should be called through qtbot, and when to use each; done means the documentation resolves the reported AttributeError and Enter-key use case.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation, testing
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.