diff --git a/tests/conftest.py b/tests/conftest.py index 6ca235383..f9a21b92a 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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.""" diff --git a/tests/integration/features/test_features.py b/tests/integration/features/conftest.py similarity index 50% rename from tests/integration/features/test_features.py rename to tests/integration/features/conftest.py index df93433d0..35599d98a 100644 --- a/tests/integration/features/test_features.py +++ b/tests/integration/features/conftest.py @@ -1,34 +1,6 @@ -# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: - -# Copyright 2015 Florian Bruhin (The Compiler) -# -# 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 . - -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 (?Pprimary selection|clipboard) should ' - r'contain "(?P.*)"')) -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 diff --git a/tests/integration/features/test_backforward.py b/tests/integration/features/test_backforward.py new file mode 100644 index 000000000..81ef35d81 --- /dev/null +++ b/tests/integration/features/test_backforward.py @@ -0,0 +1,21 @@ +# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: + +# Copyright 2015 Florian Bruhin (The Compiler) +# +# 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 . + +import pytest_bdd as bdd +bdd.scenarios('backforward.feature') diff --git a/tests/integration/features/test_yankpaste.py b/tests/integration/features/test_yankpaste.py new file mode 100644 index 000000000..4b5f51474 --- /dev/null +++ b/tests/integration/features/test_yankpaste.py @@ -0,0 +1,49 @@ +# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: + +# Copyright 2015 Florian Bruhin (The Compiler) +# +# 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 . + +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 (?Pprimary selection|clipboard) should ' + r'contain "(?P.*)"')) +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