Skip to content

Commit 5156906

Browse files
committed
python3Packages.pywebview: build fix for tests
Fixes #353686 Basically the *tests/run.sh* used upstream has a few rough edges and this replaces it with a smooth version. An issue was also opened on the upstream project to maybe get this smoothed out generally. Story time for those who are curious. Basically upstream uses this as a script to call for the CI pipeline where [the builds seem to run smoothly in appveyor](https://ci.appveyor.com/project/r0x0r/pywebview/builds/50791017). However the general structure of the script iterates over the files, which in earlier versions had been done by collecting the list of tests via pytest itself, which replaced the earliest implementation which was a file hard-coding all the tests to run. The latter had the benefit of being able to disable tests by commenting them out on our end, however the new version, at least for our purpose, is just a more complicated version of running pytest against the entire thing. We can't just use plain pytest however (which'd presumably be supported by nixpkgs infra already) because we still need to shove the Qt and xvfb-run shims in between. So with running pytest as a single command we are now (with this commit) able to specifically disable tests that we know to be flakey using regular pytest means. Side note here though: I personally have no idea how the wrapQtApp magics work internally (despite reading the hook), so I kept the wrapper part verbatim. Now on to the actual failing tests, apparently those happened to be related to relative paths which use an internal HTTP server to be served (for absolute paths this is optional), and getting rid of the cwd shenanigans which were required by the upstream version of the script (since it globbed on the current directory) means that somehow pytest now runs these tests without changing directory in a subprocess so the asset used for testing is properly accessible (before this change one could "fix" the tests by changing to an absolute path in the tests). Signed-off-by: benaryorg <binary@benary.org>
1 parent 12a7a39 commit 5156906

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

pkgs/development/python-modules/pywebview/default.nix

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,16 @@ buildPythonPackage rec {
5555
# QStandardPaths: XDG_RUNTIME_DIR not set
5656
export XDG_RUNTIME_DIR=$HOME/xdg-runtime-dir
5757
58-
pushd tests
59-
substituteInPlace run.sh \
60-
--replace "PYTHONPATH=.." "PYTHONPATH=$PYTHONPATH" \
61-
--replace "pywebviewtest test_js_api.py::test_concurrent ''${PYTEST_OPTIONS}" "# skip flaky test_js_api.py::test_concurrent"
58+
cat > tests/run.sh <<"END"
59+
#!/usr/bin/env bash
60+
export PYWEBVIEW_LOG=debug
61+
python3 -m pytest --deselect tests/test_js_api.py::test_concurrent
62+
END
6263
63-
patchShebangs run.sh
64-
wrapQtApp run.sh
64+
patchShebangs tests/run.sh
65+
wrapQtApp tests/run.sh
6566
66-
xvfb-run -s '-screen 0 800x600x24' ./run.sh
67-
popd
67+
xvfb-run -s '-screen 0 800x600x24' tests/run.sh
6868
'';
6969

7070
pythonImportsCheck = [ "webview" ];

0 commit comments

Comments
 (0)