Reorganize bdd tests.
This commit is contained in:
parent
bb4152d705
commit
ce6ba605e4
@ -118,6 +118,16 @@ def pytest_collection_modifyitems(items):
|
||||
_apply_platform_markers(item)
|
||||
|
||||
|
||||
def pytest_ignore_collect(path):
|
||||
"""Ignore BDD tests during collection if frozen."""
|
||||
rel_path = path.relto(os.path.dirname(__file__))
|
||||
if (rel_path == os.path.join('integration', 'features') and
|
||||
hasattr(sys, 'frozen')):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
@pytest.fixture(scope='session')
|
||||
def qapp(qapp):
|
||||
"""Change the name of the QApplication instance."""
|
||||
|
@ -1,34 +1,6 @@
|
||||
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et:
|
||||
|
||||
# Copyright 2015 Florian Bruhin (The Compiler) <mail@qutebrowser.org>
|
||||
#
|
||||
# This file is part of qutebrowser.
|
||||
#
|
||||
# qutebrowser is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# qutebrowser is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import sys
|
||||
import logging
|
||||
|
||||
import pytest
|
||||
|
||||
from PyQt5.QtGui import QClipboard
|
||||
|
||||
if hasattr(sys, 'frozen'):
|
||||
pytest.skip("test")
|
||||
else:
|
||||
import pytest_bdd as bdd
|
||||
bdd.scenarios('.')
|
||||
import pytest_bdd as bdd
|
||||
|
||||
|
||||
@bdd.given(bdd.parsers.parse("I set {sect} -> {opt} to {value}"))
|
||||
@ -57,12 +29,6 @@ def reload(qtbot, httpbin, quteproc, command):
|
||||
quteproc.send_cmd(':reload')
|
||||
|
||||
|
||||
@bdd.when("selection is supported")
|
||||
def selection_supported(qapp):
|
||||
if not qapp.clipboard().supportsSelection():
|
||||
pytest.skip("OS doesn't support primary selection!")
|
||||
|
||||
|
||||
@bdd.then(bdd.parsers.parse("{path} should be loaded"))
|
||||
def path_should_be_loaded(httpbin, path):
|
||||
requests = httpbin.get_requests()
|
||||
@ -87,19 +53,3 @@ def expect_error(quteproc, httpbin, category, message):
|
||||
quteproc.mark_expected(category='message',
|
||||
loglevel=category_to_loglevel[category],
|
||||
message=message)
|
||||
|
||||
|
||||
@bdd.then(bdd.parsers.re(r'the (?P<what>primary selection|clipboard) should '
|
||||
r'contain "(?P<content>.*)"'))
|
||||
def clipboard_contains(qapp, httpbin, what, content):
|
||||
if what == 'clipboard':
|
||||
mode = QClipboard.Clipboard
|
||||
elif what == 'primary selection':
|
||||
mode = QClipboard.Selection
|
||||
else:
|
||||
raise AssertionError
|
||||
|
||||
expected = content.replace('(port)', str(httpbin.port))
|
||||
|
||||
data = qapp.clipboard().text(mode=mode)
|
||||
assert data == expected
|
21
tests/integration/features/test_backforward.py
Normal file
21
tests/integration/features/test_backforward.py
Normal file
@ -0,0 +1,21 @@
|
||||
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et:
|
||||
|
||||
# Copyright 2015 Florian Bruhin (The Compiler) <mail@qutebrowser.org>
|
||||
#
|
||||
# This file is part of qutebrowser.
|
||||
#
|
||||
# qutebrowser is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# qutebrowser is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import pytest_bdd as bdd
|
||||
bdd.scenarios('backforward.feature')
|
49
tests/integration/features/test_yankpaste.py
Normal file
49
tests/integration/features/test_yankpaste.py
Normal file
@ -0,0 +1,49 @@
|
||||
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et:
|
||||
|
||||
# Copyright 2015 Florian Bruhin (The Compiler) <mail@qutebrowser.org>
|
||||
#
|
||||
# This file is part of qutebrowser.
|
||||
#
|
||||
# qutebrowser is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# qutebrowser is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import pytest
|
||||
|
||||
from PyQt5.QtGui import QClipboard
|
||||
|
||||
import pytest_bdd as bdd
|
||||
|
||||
|
||||
bdd.scenarios('yankpaste.feature')
|
||||
|
||||
|
||||
@bdd.when("selection is supported")
|
||||
def selection_supported(qapp):
|
||||
if not qapp.clipboard().supportsSelection():
|
||||
pytest.skip("OS doesn't support primary selection!")
|
||||
|
||||
|
||||
@bdd.then(bdd.parsers.re(r'the (?P<what>primary selection|clipboard) should '
|
||||
r'contain "(?P<content>.*)"'))
|
||||
def clipboard_contains(qapp, httpbin, what, content):
|
||||
if what == 'clipboard':
|
||||
mode = QClipboard.Clipboard
|
||||
elif what == 'primary selection':
|
||||
mode = QClipboard.Selection
|
||||
else:
|
||||
raise AssertionError
|
||||
|
||||
expected = content.replace('(port)', str(httpbin.port))
|
||||
|
||||
data = qapp.clipboard().text(mode=mode)
|
||||
assert data == expected
|
Loading…
Reference in New Issue
Block a user