pytest-dev / pytest-dev/pytest-qt

Docs out of sync for `qt_api`

Open
#371 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Hello! Had a test fail with 4.0.0 like:

    @pytest.fixture
    def spawn_terminal(qtbot, blank_pilot_db):
        prefs.clear()
        prefs.set('AGENT', 'TERMINAL')
        pilot_db_fn = blank_pilot_db
        prefs.set('PILOT_DB', pilot_db_fn)
>      app = qt_api.QApplication.instance()

E       AttributeError: '_QtApi' object has no attribute 'QApplication'

after looking around closed issues it looks like using qt_api directly has largely been deprecated: https://github.com/pytest-dev/pytest-qt/pull/358 and https://github.com/pytest-dev/pytest-qt/issues/365 so I think i'll be able to fix it, but the docs still say to use qt_api to test QApplication objects this way:

https://pytest-qt.readthedocs.io/en/latest/qapplication.html?highlight=qt_api#testing-custom-qapplications

from pytestqt.qt_compat import qt_api

class CustomQApplication(qt_api.QtWidgets.QApplication):
    def __init__(self, *argv):
        super().__init__(*argv)
        self.custom_attr = "xxx"

    def custom_function(self):
        pass

I realize the reference i'm using: qt_api.QApplication is different than qt_api.QtWidgets.QApplication but if i'm reading right i should just use QApplication itself? or is that a special case vs. the recommendation to do so with QWidgets eg here: https://github.com/pytest-dev/pytest-qt/issues/365 ?

seems like a reasonably quick fix to the docs, just lettin ya know :)

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 linked qapplication documentation page and compare its qt_api example with the referenced pytest-qt pull request and issue. Confirm the current QApplication access pattern, update the example accordingly, and verify the documentation no longer recommends the failing API usage.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation
Issue type
Documentation
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.