diff options
author | Florian Bruhin <me@the-compiler.org> | 2020-05-28 18:08:53 +0200 |
---|---|---|
committer | Florian Bruhin <me@the-compiler.org> | 2020-05-28 18:08:53 +0200 |
commit | ac7a3ce861b9c564749fa6961ee43b98dbca462b (patch) | |
tree | dfa15fd305deca1acb3d7206b58964e354b619b7 | |
parent | a31e93c69289223c1f6db3366b5c66db02e67c7b (diff) | |
download | qutebrowser-ac7a3ce861b9c564749fa6961ee43b98dbca462b.tar.gz qutebrowser-ac7a3ce861b9c564749fa6961ee43b98dbca462b.zip |
tests: Don't use ";;" for caret tests
If we chain two commands, the end2end test code will still only wait for
"command called: *" once. This causes all future waits to be "shifted" by one,
which can cause flaky tests on Windows.
All other usages of command chaining in tests actually *need* the second
command to run as soon as possible after the original one. However, for the
caret tests, we only need to run two commands, see
2b0870084b9185b8f8a12639d238c12b202d3284.
Because pytest-bdd doesn't allow us to re-use "Given" steps, and "Background:"
only accepts "Given", let's add a second "Given" step as an ugly but acceptable
hack. See https://github.com/pytest-dev/pytest-bdd/issues/157
See https://github.com/qutebrowser/qutebrowser/issues/5390#issuecomment-622885572
-rw-r--r-- | tests/end2end/features/caret.feature | 3 | ||||
-rw-r--r-- | tests/end2end/features/conftest.py | 11 |
2 files changed, 13 insertions, 1 deletions
diff --git a/tests/end2end/features/caret.feature b/tests/end2end/features/caret.feature index e540bafcb..ec45efaea 100644 --- a/tests/end2end/features/caret.feature +++ b/tests/end2end/features/caret.feature @@ -5,7 +5,8 @@ Feature: Caret mode Background: Given I open data/caret.html - And I run :tab-only ;; enter-mode caret + And I run :tab-only + And I also run :enter-mode caret # :yank selection diff --git a/tests/end2end/features/conftest.py b/tests/end2end/features/conftest.py index 6ac5f281d..c1e7e32ae 100644 --- a/tests/end2end/features/conftest.py +++ b/tests/end2end/features/conftest.py @@ -152,6 +152,17 @@ def run_command_given(quteproc, command): quteproc.send_cmd(command) +@bdd.given(bdd.parsers.parse("I also run {command}")) +def run_command_given_2(quteproc, command): + """Run a qutebrowser command. + + Separate from the above as a hack to run two commands in a Background + without having to use ";;". This is needed because pytest-bdd doesn't allow + re-using a Given step... + """ + quteproc.send_cmd(command) + + @bdd.given("I have a fresh instance") def fresh_instance(quteproc): """Restart qutebrowser instance for tests needing a fresh state.""" |