test requirements: Update to pytest-bdd 2.17.0
This also allows us to have dynamic pyqt>=5.3.1 etc. tags.
This commit is contained in:
parent
f6fbb098cc
commit
8d9a699b5b
@ -16,7 +16,7 @@ parse==1.6.6
|
|||||||
parse-type==0.3.4
|
parse-type==0.3.4
|
||||||
py==1.4.31
|
py==1.4.31
|
||||||
pytest==2.9.2
|
pytest==2.9.2
|
||||||
pytest-bdd==2.16.1
|
pytest-bdd==2.17.0
|
||||||
pytest-catchlog==1.2.2
|
pytest-catchlog==1.2.2
|
||||||
pytest-cov==2.2.1
|
pytest-cov==2.2.1
|
||||||
pytest-faulthandler==1.3.0
|
pytest-faulthandler==1.3.0
|
||||||
|
@ -12,7 +12,6 @@ markers =
|
|||||||
frozen: Tests which can only be run if sys.frozen is True.
|
frozen: Tests which can only be run if sys.frozen is True.
|
||||||
integration: Tests which test a bigger portion of code
|
integration: Tests which test a bigger portion of code
|
||||||
end2end: End to end tests which run qutebrowser as subprocess
|
end2end: End to end tests which run qutebrowser as subprocess
|
||||||
pyqt531_or_newer: Needs PyQt 5.3.1 or newer.
|
|
||||||
xfail_norun: xfail the test with out running it
|
xfail_norun: xfail the test with out running it
|
||||||
ci: Tests which should only run on CI.
|
ci: Tests which should only run on CI.
|
||||||
flaky_once: Try to rerun this test once if it fails
|
flaky_once: Try to rerun this test once if it fails
|
||||||
|
@ -21,9 +21,11 @@
|
|||||||
|
|
||||||
"""The qutebrowser test suite conftest file."""
|
"""The qutebrowser test suite conftest file."""
|
||||||
|
|
||||||
|
import re
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import warnings
|
import warnings
|
||||||
|
import operator
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
import hypothesis
|
import hypothesis
|
||||||
@ -35,6 +37,8 @@ from helpers.fixtures import * # pylint: disable=wildcard-import
|
|||||||
|
|
||||||
from PyQt5.QtCore import PYQT_VERSION
|
from PyQt5.QtCore import PYQT_VERSION
|
||||||
|
|
||||||
|
from qutebrowser.utils import qtutils
|
||||||
|
|
||||||
|
|
||||||
# Set hypothesis settings
|
# Set hypothesis settings
|
||||||
hypothesis.settings.register_profile('default',
|
hypothesis.settings.register_profile('default',
|
||||||
@ -54,8 +58,6 @@ def _apply_platform_markers(item):
|
|||||||
"Can't be run when frozen"),
|
"Can't be run when frozen"),
|
||||||
('frozen', not getattr(sys, 'frozen', False),
|
('frozen', not getattr(sys, 'frozen', False),
|
||||||
"Can only run when frozen"),
|
"Can only run when frozen"),
|
||||||
('pyqt531_or_newer', PYQT_VERSION < 0x050301,
|
|
||||||
"Needs PyQt 5.3.1 or newer"),
|
|
||||||
('ci', 'CI' not in os.environ, "Only runs on CI."),
|
('ci', 'CI' not in os.environ, "Only runs on CI."),
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -183,3 +185,43 @@ def pytest_sessionfinish(exitstatus):
|
|||||||
status_file = os.path.join(cache_dir, 'pytest_status')
|
status_file = os.path.join(cache_dir, 'pytest_status')
|
||||||
with open(status_file, 'w', encoding='ascii') as f:
|
with open(status_file, 'w', encoding='ascii') as f:
|
||||||
f.write(str(exitstatus))
|
f.write(str(exitstatus))
|
||||||
|
|
||||||
|
|
||||||
|
def pytest_bdd_apply_tag(tag, function):
|
||||||
|
version_re = re.compile("""
|
||||||
|
(?P<package>qt|pyqt)
|
||||||
|
(?P<operator>==|>|>=|<|<=|!=)
|
||||||
|
(?P<version>\d+\.\d+\.\d+)
|
||||||
|
""", re.VERBOSE)
|
||||||
|
|
||||||
|
match = version_re.match(tag)
|
||||||
|
if not match:
|
||||||
|
# Use normal tag mapping
|
||||||
|
return None
|
||||||
|
|
||||||
|
operators = {
|
||||||
|
'==': operator.eq,
|
||||||
|
'>': operator.gt,
|
||||||
|
'<': operator.lt,
|
||||||
|
'>=': operator.ge,
|
||||||
|
'<=': operator.le,
|
||||||
|
'!=': operator.ne,
|
||||||
|
}
|
||||||
|
|
||||||
|
package = match.group('package')
|
||||||
|
op = operators[match.group('operator')]
|
||||||
|
version = match.group('version')
|
||||||
|
|
||||||
|
if package == 'qt':
|
||||||
|
mark = pytest.mark.skipif(qtutils.version_check(version, op),
|
||||||
|
reason='Needs ' + tag)
|
||||||
|
elif package == 'pyqt':
|
||||||
|
major, minor, patch = [int(e) for e in version.split('.')]
|
||||||
|
hex_version = (major << 16) | (minor << 8) | patch
|
||||||
|
mark = pytest.mark.skipif(not op(PYQT_VERSION, hex_version),
|
||||||
|
reason='Needs ' + tag)
|
||||||
|
# else:
|
||||||
|
raise ValueError("Invalid package {}".format(package))
|
||||||
|
|
||||||
|
mark(function)
|
||||||
|
return True
|
||||||
|
@ -40,7 +40,7 @@ Feature: Prompts
|
|||||||
And I run :leave-mode
|
And I run :leave-mode
|
||||||
Then the javascript message "confirm reply: false" should be logged
|
Then the javascript message "confirm reply: false" should be logged
|
||||||
|
|
||||||
@pyqt531_or_newer
|
@pyqt>=5.3.1
|
||||||
Scenario: Javascript prompt
|
Scenario: Javascript prompt
|
||||||
When I open data/prompt/jsprompt.html
|
When I open data/prompt/jsprompt.html
|
||||||
And I click the button
|
And I click the button
|
||||||
@ -49,7 +49,7 @@ Feature: Prompts
|
|||||||
And I run :prompt-accept
|
And I run :prompt-accept
|
||||||
Then the javascript message "Prompt reply: prompt test" should be logged
|
Then the javascript message "Prompt reply: prompt test" should be logged
|
||||||
|
|
||||||
@pyqt531_or_newer
|
@pyqt>=5.3.1
|
||||||
Scenario: Rejected javascript prompt
|
Scenario: Rejected javascript prompt
|
||||||
When I open data/prompt/jsprompt.html
|
When I open data/prompt/jsprompt.html
|
||||||
And I click the button
|
And I click the button
|
||||||
@ -61,7 +61,7 @@ Feature: Prompts
|
|||||||
|
|
||||||
# Shift-Insert with prompt (issue 1299)
|
# Shift-Insert with prompt (issue 1299)
|
||||||
|
|
||||||
@pyqt531_or_newer
|
@pyqt>=5.3.1
|
||||||
Scenario: Pasting via shift-insert in prompt mode
|
Scenario: Pasting via shift-insert in prompt mode
|
||||||
When selection is supported
|
When selection is supported
|
||||||
And I put "insert test" into the primary selection
|
And I put "insert test" into the primary selection
|
||||||
@ -72,7 +72,7 @@ Feature: Prompts
|
|||||||
And I run :prompt-accept
|
And I run :prompt-accept
|
||||||
Then the javascript message "Prompt reply: insert test" should be logged
|
Then the javascript message "Prompt reply: insert test" should be logged
|
||||||
|
|
||||||
@pyqt531_or_newer
|
@pyqt>=5.3.1
|
||||||
Scenario: Using content -> ignore-javascript-prompt
|
Scenario: Using content -> ignore-javascript-prompt
|
||||||
When I set content -> ignore-javascript-prompt to true
|
When I set content -> ignore-javascript-prompt to true
|
||||||
And I open data/prompt/jsprompt.html
|
And I open data/prompt/jsprompt.html
|
||||||
|
Loading…
Reference in New Issue
Block a user