Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs out of sync for qt_api #371

Open
sneakers-the-rat opened this issue Jun 5, 2021 · 2 comments
Open

Docs out of sync for qt_api #371

sneakers-the-rat opened this issue Jun 5, 2021 · 2 comments

Comments

@sneakers-the-rat
Copy link

sneakers-the-rat commented Jun 5, 2021

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: #358 and #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: #365 ?

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

@nicoddemus
Copy link
Member

Thanks @sneakers-the-rat for the report!

Perhaps would you like to contribute that fix? It would certainly be appreciated. 😁

@The-Compiler
Copy link
Member

Not really sure what to best do about this. So far we've always said that qt_compat isn't really intended as public API, but at the same time we're using it for writing the docs indeed.

We could rewrite the docs to use a specific Qt wrapper instead, but that'd mean we'd implicitly "recommend" one of them (then again, we're already kinda doing that with the precedence for PYTEST_QT_API), and it'd also make it much harder if we wanted to introduce doc-testing for our docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants