Remove some unnecessary "fresh instances" in tests

With the addition of :window-only, it's no longer necessary to use
"Given I have a fresh instance" to clean up previous windows. This
greatly cuts down on the amount of process restarts that need to happen
to complete a full testing cycle.

I also made one of the tests more robust against order alterations, and
removed some unnecessary extra commands that were already implied by the
background on others.
This commit is contained in:
Niklas Haas 2016-08-12 00:00:18 +02:00
parent d5080bdb1a
commit b6145d98a4
No known key found for this signature in database
GPG Key ID: 9A09076581B27402
5 changed files with 21 additions and 37 deletions

View File

@ -108,7 +108,7 @@ Feature: Going back and forward.
And the message "Still alive!" should be shown
Scenario: Going back in a new window
Given I have a fresh instance
Given I clean up open tabs
When I open data/backforward/1.txt
And I open data/backforward/2.txt
And I run :back -w

View File

@ -139,6 +139,15 @@ def fresh_instance(quteproc):
quteproc.start()
@bdd.given("I clean up open tabs")
def clean_open_tabs(quteproc):
"""Clean up open windows and tabs."""
quteproc.set_setting('tabs', 'last-close', 'blank')
quteproc.send_cmd(':window-only')
quteproc.send_cmd(':tab-only')
quteproc.send_cmd(':tab-close')
## When

View File

@ -263,8 +263,7 @@ Feature: Tab management
Then the error "There's no tab with index -1!" should be shown
Scenario: :tab-focus last with no last focused tab
Given I have a fresh instance
And I run :tab-focus last
When I run :tab-focus last
Then the error "No last focused tab!" should be shown
# tab-prev/tab-next
@ -564,7 +563,6 @@ Feature: Tab management
- data/hello2.txt
Scenario: Cloning to new window
Given I have a fresh instance
When I open data/title.html
And I run :tab-clone -w
Then the session should look like:
@ -583,7 +581,6 @@ Feature: Tab management
title: Test title
Scenario: Cloning with tabs-are-windows = true
Given I have a fresh instance
When I open data/title.html
And I set tabs -> tabs-are-windows to true
And I run :tab-clone
@ -605,7 +602,6 @@ Feature: Tab management
# :tab-detach
Scenario: Detaching a tab
Given I have a fresh instance
When I open data/numbers/1.txt
And I open data/numbers/2.txt in a new tab
And I run :tab-detach
@ -856,7 +852,6 @@ Feature: Tab management
# :buffer
Scenario: :buffer without args
Given I have a fresh instance
When I run :buffer
Then the error "buffer: The following arguments are required: index" should be shown
@ -909,8 +904,8 @@ Feature: Tab management
Scenario: :buffer with no matching window index
When I open data/title.html
And I run :buffer "2/1"
Then the error "There's no window with id 2!" should be shown
And I run :buffer "99/1"
Then the error "There's no window with id 99!" should be shown
Scenario: :buffer with matching window index
Given I have a fresh instance
@ -942,7 +937,6 @@ Feature: Tab management
- url: http://localhost:*/data/paste_primary.html
Scenario: :buffer with wrong argument (-1)
Given I have a fresh instance
When I open data/title.html
And I run :buffer "-1"
Then the error "There's no tab with index -1!" should be shown

View File

@ -19,10 +19,3 @@
import pytest_bdd as bdd
bdd.scenarios('tabs.feature')
@bdd.given("I clean up open tabs")
def clean_open_tabs(quteproc):
quteproc.set_setting('tabs', 'last-close', 'blank')
quteproc.send_cmd(':tab-only')
quteproc.send_cmd(':tab-close')

View File

@ -3,7 +3,7 @@ Feature: Yanking and pasting.
from/to the clipboard and primary selection.
Background:
Given I run :tab-only
Given I clean up open tabs
#### :yank
@ -79,9 +79,7 @@ Feature: Yanking and pasting.
Then the error "Clipboard is empty." should be shown
Scenario: Pasting in a new tab
Given I open about:blank
When I run :tab-only
And I put "http://localhost:(port)/data/hello.txt" into the clipboard
When I put "http://localhost:(port)/data/hello.txt" into the clipboard
And I run :open -t {clipboard}
And I wait until data/hello.txt is loaded
Then the following tabs should be open:
@ -89,9 +87,7 @@ Feature: Yanking and pasting.
- data/hello.txt (active)
Scenario: Pasting in a background tab
Given I open about:blank
When I run :tab-only
And I put "http://localhost:(port)/data/hello.txt" into the clipboard
When I put "http://localhost:(port)/data/hello.txt" into the clipboard
And I run :open -b {clipboard}
And I wait until data/hello.txt is loaded
Then the following tabs should be open:
@ -99,7 +95,6 @@ Feature: Yanking and pasting.
- data/hello.txt
Scenario: Pasting in a new window
Given I have a fresh instance
When I put "http://localhost:(port)/data/hello.txt" into the clipboard
And I run :open -w {clipboard}
And I wait until data/hello.txt is loaded
@ -123,7 +118,6 @@ Feature: Yanking and pasting.
Then the error "Invalid URL" should be shown
Scenario: Pasting multiple urls in a new tab
Given I have a fresh instance
When I put the following lines into the clipboard:
http://localhost:(port)/data/hello.txt
http://localhost:(port)/data/hello2.txt
@ -139,8 +133,8 @@ Feature: Yanking and pasting.
- data/hello3.txt
Scenario: Pasting multiline text
Given I have a fresh instance
When I set searchengines -> DEFAULT to http://localhost:(port)/data/hello.txt?q={}
When I set general -> auto-search to true
And I set searchengines -> DEFAULT to http://localhost:(port)/data/hello.txt?q={}
And I put the following lines into the clipboard:
this url:
http://qutebrowser.org
@ -152,9 +146,8 @@ Feature: Yanking and pasting.
- data/hello.txt?q=this%20url%3A%0Ahttp%3A//qutebrowser.org%0Ashould%20not%20open (active)
Scenario: Pasting multiline whose first line looks like a URI
Given I open about:blank
When I run :tab-only
When I set searchengines -> DEFAULT to http://localhost:(port)/data/hello.txt?q={}
When I set general -> auto-search to true
And I set searchengines -> DEFAULT to http://localhost:(port)/data/hello.txt?q={}
And I put the following lines into the clipboard:
text:
should open
@ -166,9 +159,7 @@ Feature: Yanking and pasting.
- data/hello.txt?q=text%3A%0Ashould%20open%0Aas%20search (active)
Scenario: Pasting multiple urls in a background tab
Given I open about:blank
When I run :tab-only
And I put the following lines into the clipboard:
When I put the following lines into the clipboard:
http://localhost:(port)/data/hello.txt
http://localhost:(port)/data/hello2.txt
http://localhost:(port)/data/hello3.txt
@ -183,7 +174,6 @@ Feature: Yanking and pasting.
- data/hello3.txt
Scenario: Pasting multiple urls in new windows
Given I have a fresh instance
When I put the following lines into the clipboard:
http://localhost:(port)/data/hello.txt
http://localhost:(port)/data/hello2.txt
@ -216,13 +206,11 @@ Feature: Yanking and pasting.
url: http://localhost:*/data/hello3.txt
Scenario: Pasting multiple urls with an empty one
When I open about:blank
And I put "http://localhost:(port)/data/hello.txt\n\nhttp://localhost:(port)/data/hello2.txt" into the clipboard
And I run :open -t {clipboard}
Then no crash should happen
Scenario: Pasting multiple urls with an almost empty one
When I open about:blank
And I put "http://localhost:(port)/data/hello.txt\n \nhttp://localhost:(port)/data/hello2.txt" into the clipboard
And I run :open -t {clipboard}
Then no crash should happen