Commit Graph

213 Commits

Author SHA1 Message Date
Florian Bruhin c5e7a73ab7 tests: Set pythonpath in pytest.ini
Makes pytest work without PYTHONPATH=. if running outside tox.
2025-10-22 16:03:46 +02:00
Florian Bruhin 4d6dccfed5 Qt 6.10: Ignore new logging messages
See #8694
2025-09-09 22:07:55 +02:00
Florian Bruhin d80d80b867 Qt 6.10: Adjust CI test skipping 2025-07-21 13:47:45 +02:00
Florian Bruhin c79257dc8d Remove pytest-mock pytest warning ignore
Fixed in pytest-mock 3.14.1
2025-07-08 21:15:15 +02:00
Florian Bruhin ed99c82440 tests: Fix pattern 2025-05-06 14:41:13 +02:00
Florian Bruhin 20a9130cee Ignore a random Qt 5 log message
No idea where this came from...
2025-05-06 14:27:57 +02:00
Florian Bruhin 3280c8dacc tests: Avoid CI issues with qutescheme and Qt 6.9
see #8536
2025-04-08 14:03:26 +02:00
Florian Bruhin 65a3a3cf9a Python 3.14: Ignore DeprecationWarnings in plugins
https://github.com/pytest-dev/pytest-mock/issues/468
https://github.com/ionelmc/pytest-benchmark/issues/283

Part of #8529
2025-04-02 13:15:32 +02:00
Florian Bruhin b0e05ee160 Qt 6.9: Only disable software rendering for darkmode tests
Looks like the "tests hanging" issue was fixed between Beta 3 and RC.

See #8444
2025-03-15 16:49:43 +01:00
Florian Bruhin 328b5966ef Add initial support for running tests offscreen
Makes

    QT_QPA_PLATFORM=offscreen pytest

pass.

See #4914
2025-03-12 14:41:50 +01:00
Florian Bruhin 4cc67d3603 Qt 6.9: Force software rendering for tests
Not yet quite sure what exactly is the culprit, but this seems to help for all
tests (!) to pass with Xvfb locally.

For now only scoped to Qt 6.9.0. Will probably already need to reevaluate with
the RC, but definitely with the final release.

See #8444
2025-03-12 14:41:32 +01:00
Florian Bruhin 7b4c163142 Qt 6.9: Add additional error message ignores
See #8444
2025-03-11 18:01:45 +01:00
Florian Bruhin ed8141cb4b tests: Improve handling of qutescheme on Qt 6.9 CI
See #8444
2025-01-06 15:14:21 +01:00
Florian Bruhin 3934d727e4 Qt 6.9: xfail failing test on CI for now
Probably not our fault, and shouldn't break CI until we figure out what could be
going on there...

See https://github.com/qutebrowser/qutebrowser/issues/8444#issuecomment-2569610110
2025-01-03 19:04:36 +01:00
Florian Bruhin f056f49bd1 tests: Fix file path matching on Windows
Qt 6.8 change?
2024-12-10 00:35:29 +01:00
Florian Bruhin 48d3c7d97c py313: Ignore maxsplit deprecation warning
2f48300931
https://github.com/pytest-dev/pytest-bdd/issues/752
https://github.com/pytest-dev/pytest-bdd/pull/753

See #8205
2024-12-09 16:06:54 +01:00
Florian Bruhin a1d89a83b0 Merge remote-tracking branch 'origin/pr/8348' 2024-12-04 20:40:19 +01:00
Florian Bruhin f382a1a18f Remove pytest-benchmark filterwarning 2024-11-10 19:36:51 +01:00
toofar f551bbbb76 Move new permission API check from pytest markers to BDD step
For tests that do the same prompt in the same session, they are failing
on Qt6.8 and PyQWebEnginet6.7 because we can't disable the new WebEngine
behaviour.

We can work around this by getting a fresh instance for each test, but I
don't want to make more tests slower if I don't have to. So move that
logic into a custom "fresh instance" prompt that will only create one
when needed.
2024-10-28 15:26:25 +13:00
toofar 8064e3ea6f Disable QtWebEngine's permissions persistence feature
QtWebEngine has a new feature where it will remember what permissions
you have granted or denied. It has three options regarding permissions
storage:

    AskEveryTime -- don't store
    StoreInMemory -- store in memory only
    StoreOnDisk -- store in memory and on disk

By default it does the StoreOnDisk behavior. Having webengine remember
whether you granted or denied a permission would make the qutebrowser UX
around that area inconsistent. For example the default y/n actions for a
permission prompt in qutebrowser will only accept that single
permission request, and you'll be re-prompted if you reload the page.
Users may be used to this and if webengine started remembering
permission grants the users may be surprised to find that the page was
accessing features without prompting them for permission anymore.
Additionally we already have our own permission storage machinery in
autoconfig.yml.

This commit will set the webengine feature to AskEveryTime, which disables
any storing of permission grants.

Also adjusts the skip marker of the affected tests so they'll be enabled
again on Qt versions with the appropriate permissions API.
2024-10-27 12:48:46 +13:00
toofar 3bc30e748d Merge pull request #8243 from feat/e2e_screenshots 2024-10-05 11:30:57 +13:00
toofar a05cbe4f30 Adjust permission tests for changes to 6.8 permission storage feature
Qt have updated their permission storage feature so it respects our
the setting our basedir feature uses, so now all the tests that use
"Given I have a fresh instance" are passing.

The remaining failing ones do pass if I make them run in a fresh
instance, but I am leaving them as xfail because a) opening a new
instance is slow b) the new upstream behaviour causes a regression in
the qutebrowser behavior (you don't get re-prompted where you would have
been previously) so I feel like it is correct for some tests to be
failing! We have to set AskEveryTime at some point and we can address
them then.
2024-09-06 19:53:06 +12:00
toofar 4ba0e00bbd Ignore no dictionary errors on CI
The message is:

    The following paths were searched for Qt WebEngine dictionaries:
      /tmp/qutebrowser-basedir-qrhbqblr/data/qtwebengine_dictionaries
    but could not find it.
    Spellchecking can not be enabled.

Tests are failing on "Logged unexpected errors".
2024-09-06 18:13:21 +12:00
toofar a3238eb494 upload e2e failure screenshots as artifacts
This commit takes a screenshot of the active browser window when an
end2end test fails. When running on CI a zip file of screenshots will be
attached to the run summary as an artifact. When run locally screenshots
will be left in /$TMPDIR/pytest-screenshots/.

The screenshot is of the Xvfb screen that the tests are running under.
If there are multiple windows open it will likely only show the active
window because a) we aren't running with a window manager b) the Xvfb
display is, by default, the same size as the browser window.

I'm not sure if xvfb is used on the Window runs in CI. We could fall
back to trying to take screenshots if not running under xvfb but I'm a
bit wary of an automatic feature that takes screenshots of people's
desktops when running locally. Even if they just to to /tmp/ it might be
surprising. We can change it later if it turns out we need to try to
take screenshots in more cases.

I'm using pillow ImageGrab, the same as pyvirtualdisplay.smartdisplay. I'm
getting the display number from the pytest-xvfb plugin and formatting it
appropriately (pyvirtualdisplay has an already formatted one which is used by
the smartdisplay, but that's not accessible).

Pillow is now a requirement for running the tests. I thought about making
it gracefully not required but I'm not sure how to inform the user with
a warning from pytest, or if they would even want one. Maybe we could
add a config thing to allow not taking screenshots?

I had to bump the colordepth config for pytest-xvfb otherwise pillow
complained that the default 16bit color depth wasn't supported as it
only supports 24bit, see https://github.com/python-pillow/Pillow/blob/1138ea5370cbda5eb328ec949
8c314d376c81265/src/display.c#L898

I'm saving screenshots to a temp dir because I don't want to put them in
my workdir when running locally. I want to clear the directory for each
run so that you don't get confused by looking at old images. I'm not
100% sure about the lifecycle of the process classes though. Eg if we
have two processes they might both try to create the output directory.
I'm using pytest.session.stash to save the directory so perhaps the
lifecycle of the stash will handle that? Not sure.

Ideally the images would be uploaded somewhere where we could click
through and open them in the browser without having to download a zip
file, but I'm not sure how to achieve that.

It would be nice to print in the test logs that a screenshot was saved
and where to. Just so you could copy paste the filename instead of
having to match the sanitized filename against failing test names. But I
don't know how to log stuff from this stage in the pytest lifecycle.

TODO:
* I'm not sure that the screenshot captures the whole browser window?
  Maybe the browser windows is bigger than the X11 display?

Closes: #7625
2024-08-18 12:42:29 +12:00
toofar 68755ed850 Change Qt6.8 failing permission test xfail to "skip"
The "Async question interrupted by async one" test was failing on CI but
not locally. Not sure why, changing the tests to skip instead of xfail.
The downside is that we won't bet a notification when upstream fixes the
issues, hopefully they mark the QTBUG as closed and we see it that way.
I think we do have to do something else to deal with this persistent
permission thing anyway, assuming they don't change it to be
off-by-default, so I'm sure we'll be looking in this area again!

They'll at the very least be re-enabled when we get a PyQt 6.8.
2024-06-23 20:11:25 +12:00
toofar 9ffa98535f Ignore QSaveFile::commit warning message in tests
The test (`test_failing_flush()`) is deliberately trying to write to a
close file. This is a new error in Qt 6.8 it seems.

Ignore just the specific file for this test in case it pops up somewhere
else later.
2024-06-23 20:11:25 +12:00
toofar 39f8ce5130 XFail permission tests that have changed behavior on 6.8
WebEngine now has it's own mechanism to remember permission, and it's
turned on by default. We can't disable it until PyQt picks up the new
`QWebEngineProfile::setPersistentPermissionsPolicy()`. So the first test
that prompts for a permission will persist that setting and later ones
will fail because they don't get the prompt they expect.

For now lets set them to xfail while we figure out what to do with
permission persisting for actual users. That we we can reduce the noise
in the test results!

The WebEngine permissions persistence mechanism doesn't seem to
respect whatever we are doing to separate storage per-basedir. Testing
with a temp basedir like so:

    python3 -m qutebrowser -T https://web-push-book.gauntface.com/demos/notification-examples/

I see this file has been created under my home directory:

    $ cat ~/.local/share/qutebrowser/qutebrowser/QtWebEngine/Default/permissions.json
    {"Notifications":{"https://web-push-book.gauntface.com/":true}}

I've raised an issue upstream about that here: https://bugreports.qt.io/browse/QTBUG-126595

We've got two things to think about regarding how to deal with this new
on-by-default feature:

1. what do we do for the tests? We can Disable the feature (if on new
   enough PyQt) or add a test setup step that ... restarts the browser
   and deletes the permissions.json. That's not great
2. what do we do for real users? See below

By default I would recommend disabling the webengine one since we
already have our own. BUT we can't actually disable it until PyQt
updates with the new APIs, which can take a while, and it's pretty
likely people will be using the new Qt version before PyQt updates. So
it would be best to figure out what we can do before that! Can we make
it respect the basedir data path? Can we make it write to some fake file
we throwaway? chmod +i?

Hopefully Qt makes the permission JSON respect the data path we set and
then at the very least we can remove the JSON file after a permission is
set. It'll still be a change in behavior for users on Qt 6.8 and PyQt
6.7 though as it'll likely remember permissions within a browser
instance by default, which isn't the case for our implementation
currently.

Related to: https://github.com/qutebrowser/qutebrowser/issues/8242#issuecomment-2175949686
2024-06-23 20:11:25 +12:00
toofar fe81422f94 Ignore QItemSelectionModel no-op message.
This starts happening reliably with the "Using session completion" end
to end test after the previous change where I made it so we don't set
the completion widget model to none, just call `deleteLater()` on the old
one. The relevant part of the test is:

        And I run :session-save hello
        # This loads a completion model with one entry
        When I run :cmd-set-text -s :session-load
        # This one selects the entry, which clears the model because the
        # session completion only applies to the first word after the
        # command, which we've just selected.
        And I run :completion-item-focus next
        # This does nothing, since we have no completion model loaded,
        # not sure why it is in the test, presumably making sure no
        # exception is thrown.
        And I run :completion-item-focus next

The log message is reliable in the test but it's a bit flaky to
reproduce manually. I've reproduced it via `for f in 1 2;do qute-send -i
/tmp/qutebrowser-basedir-npzdpupy/runtime/ipc-8075cf54f63b8e1bc05db34f41292c38
":completion-item-focus next" ;done` if I manually go through the
scenario a few times. Possibly it would reproduce easier if I pin it to
one process using `taskset`.

I think the reason for this is that the model is marked for deletion in
the next event loop, then a signal goes out, then the selection model is
marked for deletion on the next event loop. And possibly this only
happens between the model and the selection model being deleted?
2024-06-09 18:16:01 +12:00
Florian Bruhin f72b862da5 tests: Re-add pytest-benchmark warning ignore
This was fixed but never released...
2024-05-24 17:07:52 +02:00
Florian Bruhin f1c18360a2 tests: Remove warning ignores for fixed issues 2024-05-23 08:12:30 +02:00
Florian Bruhin 9bf0393923 tests: Don't make QSslSocket error fail tests
Bleeding environment fails tests/unit/browser/webkit/test_certificateerror.py on Qt 5, maybe due to OpenSSL 3.x
2024-05-16 09:31:42 +02:00
toofar b812ec2628 Ignore more 6.7 DIR_APP_DICTIONARIOES log messages
In the bleeding edge CI tests I'm seeing:

  IGNORED: Path override failed for key base::DIR_APP_DICTIONARIES and path '/__w/qutebrowser/qutebrowser/.tox/bleeding/lib/python3.11/sitePath override failed for key base::DIR_APP_DICTIONARIES and path '/__w/qutebrowser/qutebrowser/.tox/bleeding/lib/python3.11/site-packages/PyQt6/Qt6/libexec/qtwebengine_dictionaries'
  INVALID: -packages/PyQt6/Qt6/libexec/qtwebengine_dictionaries'

Where the second line looks like maybe spill over from the first one
that is for some reason being printed twice and interleaved! Maybe
different processes or threads?

I did a regex for "line ending with this and with no spaces in it" which
is hopefully safe enough to not pick up a wrong line accidentally.
2024-04-06 11:29:31 +13:00
Florian Bruhin a45cfb89cb tests: Add new ignored error messages 2024-03-25 23:05:25 +01:00
toofar e6a0d2bf2f Ignore new 6.6.2 notifications related error messages
The seem to be non-fatal considering the test scenarios they are coming from
are still passing.
2024-02-20 18:45:33 +13:00
Florian Bruhin ae2e679dfc tests: Ignore some more irrelevant messages 2023-09-06 16:38:46 +02:00
Florian Bruhin 080ce36451 tests: Update warning ignores 2023-06-16 11:50:07 +02:00
Florian Bruhin 15e7d5c6b1 py312: Ignore pytest-benchmark deprecation warning
See #7727 and https://github.com/ionelmc/pytest-benchmark/issues/240
2023-06-09 15:02:30 +02:00
Florian Bruhin 2c61ec38b8 py312: Ignore pytest ast warnings
See https://github.com/pytest-dev/pytest/issues/10977
and #7727
2023-06-08 17:41:10 +02:00
Florian Bruhin e7723c9f25 Fix regex 2023-05-31 15:49:41 +02:00
Florian Bruhin 68e61a239d ci: Ignore spurious QPainter messages 2023-05-31 12:08:10 +02:00
Florian Bruhin 49048489c3 Revert "pytest: Ignore Python 3.12 addDuration warning"
This reverts commit ee40046faf.
2023-04-14 21:02:47 +02:00
Florian Bruhin ee40046faf pytest: Ignore Python 3.12 addDuration warning
See https://github.com/pytest-dev/pytest/issues/10875
2023-04-11 16:29:50 +02:00
Florian Bruhin 72c38a8e19 tests: Remove old pytest-instafail/hypothesis filterwarnings 2023-04-03 08:22:45 +02:00
Florian Bruhin 8227b91d28 tests: Update FIXME comment
PyQt insists using the deprecated signal overload, seemingly nothing we can do
to change that:
https://www.riverbankcomputing.com/pipermail/pyqt/2023-March/045215.html

See #7624
2023-03-17 20:08:54 +01:00
Florian Bruhin 2d45f6f002 tests: Ignore more Qt 6.5 / debug build messages
See #7624
2023-03-17 17:27:29 +01:00
toofar 2d66466194 Merge branch 'master' into qt6-v2
Just a few conflicts around CI and dependencies.
2022-11-20 15:48:00 +13:00
Florian Bruhin 1f5ad8abfb Remove pytest-bdd deprecation ignore 2022-11-08 16:20:46 +01:00
Florian Bruhin 1387c999fa Skip problematic QtWebKit tests with OpenSSL 3
See https://github.com/cherrypy/cheroot/issues/517 and #7467
2022-11-08 16:17:31 +01:00
Florian Bruhin bc225557a5 Adjust warnings and changelog URLs for new pytest 2022-10-31 08:19:25 +01:00
Florian Bruhin ef486aa263 Remove unneeded old log ignores 2022-08-23 18:31:41 +02:00