From 60c2b9c0b20a051cddf0cdd3bf0e40603dfe6bb9 Mon Sep 17 00:00:00 2001 From: Felix Van der Jeugt Date: Mon, 15 Feb 2016 21:59:09 +0100 Subject: [PATCH 1/7] fixes #1308 --- tests/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index 6b9c1feca..2bfa30603 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -425,7 +425,7 @@ def pytest_configure(config): try: disp = xvfbwrapper.Xvfb(width=800, height=600, colordepth=16) disp.start() - except FileNotFoundError: + except EnvironmentError: # We run without Xvfb if it's unavailable. pass else: From 9a18bc4cedec7b33626dcf75faf862caab22f087 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 15 Feb 2016 22:08:42 +0100 Subject: [PATCH 2/7] Regenerate authors. --- README.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.asciidoc b/README.asciidoc index 3d7c4a276..a4632f27e 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -148,8 +148,8 @@ Contributors, sorted by the number of commits in descending order: * Alexander Cogneau * Martin Tournoij * Raphael Pierzina -* Joel Torstensson * Felix Van der Jeugt +* Joel Torstensson * Claude * Patric Schmitz * meles5 From 5c617b861c2a517168c694519379982db666e971 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 16 Feb 2016 20:36:23 +0100 Subject: [PATCH 3/7] Switch to pytest-xvfb. Fixes #1309. --- pytest.ini | 2 +- tests/conftest.py | 38 ++++----------------- tests/integration/features/keyinput.feature | 2 +- tests/integration/features/misc.feature | 6 ++-- tox.ini | 2 +- 5 files changed, 12 insertions(+), 38 deletions(-) diff --git a/pytest.ini b/pytest.ini index b754af883..04ebb49c0 100644 --- a/pytest.ini +++ b/pytest.ini @@ -9,7 +9,7 @@ markers = osx: Tests which only can run on OS X. not_osx: Tests which can not run on OS X. not_frozen: Tests which can't be run if sys.frozen is True. - not_xvfb: Tests which can't be run with Xvfb. + no_xvfb: Tests which can't be run with Xvfb. frozen: Tests which can only be run if sys.frozen is True. integration: Tests which test a bigger portion of code, run without coverage. skip: Always skipped test. diff --git a/tests/conftest.py b/tests/conftest.py index ed617b854..1a38d0825 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -34,7 +34,6 @@ from helpers.messagemock import message_mock from helpers.fixtures import * # pylint: disable=wildcard-import from PyQt5.QtCore import PYQT_VERSION -import xvfbwrapper # Set hypothesis settings @@ -55,8 +54,6 @@ def _apply_platform_markers(item): "Can't be run when frozen"), ('frozen', not getattr(sys, 'frozen', False), "Can only run when frozen"), - ('not_xvfb', item.config.xvfb_display is not None, - "Can't be run with Xvfb."), ('skip', True, "Always skipped."), ('pyqt531_or_newer', PYQT_VERSION < 0x050301, "Needs PyQt 5.3.1 or newer"), @@ -147,41 +144,18 @@ def fail_tests_on_warnings(): def pytest_addoption(parser): - parser.addoption('--no-xvfb', action='store_true', default=False, - help='Disable xvfb in tests.') parser.addoption('--qute-delay', action='store', default=0, type=int, help="Delay between qutebrowser commands.") parser.addoption('--qute-profile-subprocs', action='store_true', default=False, help="Run cProfile for subprocesses.") -def pytest_configure(config): - """Start Xvfb if we're on Linux, not on a CI and Xvfb is available. - - This is a lot nicer than having windows popping up. - """ - config.xvfb_display = None - if os.environ.get('DISPLAY', None) == '': - # xvfbwrapper doesn't handle DISPLAY="" correctly - del os.environ['DISPLAY'] - - if (sys.platform.startswith('linux') and - not config.getoption('--no-xvfb') and - 'QUTE_NO_DISPLAY' not in os.environ): - assert 'QUTE_BUILDBOT' not in os.environ - try: - disp = xvfbwrapper.Xvfb(width=800, height=600, colordepth=16) - disp.start() - except EnvironmentError: - # We run without Xvfb if it's unavailable. - pass - else: - config.xvfb_display = disp - - -def pytest_unconfigure(config): - if config.xvfb_display is not None: - config.xvfb_display.stop() +@pytest.fixture(scope='session', autouse=True) +def prevent_xvfb_on_buildbot(request): + if (not request.config.getoption('--no-xvfb') and + 'QUTE_BUILDBOT' in os.environ and + request.config.xvfb is not None): + raise Exception("Xvfb is running on buildbot!") @pytest.hookimpl(tryfirst=True, hookwrapper=True) diff --git a/tests/integration/features/keyinput.feature b/tests/integration/features/keyinput.feature index eae967874..1d930da24 100644 --- a/tests/integration/features/keyinput.feature +++ b/tests/integration/features/keyinput.feature @@ -113,7 +113,7 @@ Feature: Keyboard input Then the javascript message "key press: 88" should be logged And the javascript message "key release: 88" should be logged - @not_xvfb @posix + @no_xvfb @posix Scenario: :fake-key sending key to the website with other window focused When I open data/keyinput/log.html And I set general -> developer-extras to true diff --git a/tests/integration/features/misc.feature b/tests/integration/features/misc.feature index 38a77d6e6..7a0f9ae2f 100644 --- a/tests/integration/features/misc.feature +++ b/tests/integration/features/misc.feature @@ -108,7 +108,7 @@ Feature: Various utility commands. And I run :inspector Then the error "Please enable developer-extras before using the webinspector!" should be shown - @not_xvfb @posix + @no_xvfb @posix Scenario: Inspector smoke test When I set general -> developer-extras to true And I run :inspector @@ -124,7 +124,7 @@ Feature: Various utility commands. Then the error "Please enable developer-extras before using the webinspector!" should be shown # Different code path as an inspector got created now - @not_xvfb @posix + @no_xvfb @posix Scenario: Inspector smoke test 2 When I set general -> developer-extras to true And I run :inspector @@ -202,7 +202,7 @@ Feature: Various utility commands. # :debug-console - @not_xvfb + @no_xvfb Scenario: :debug-console smoke test When I run :debug-console And I wait for "Focus object changed: " in the log diff --git a/tox.ini b/tox.ini index b64bc9815..465c393fd 100644 --- a/tox.ini +++ b/tox.ini @@ -38,12 +38,12 @@ deps = pytest-travis-fold==1.2.0 pytest-repeat==0.2 pytest-rerunfailures==1.0.1 + pytest-xvfb==0.1.0 six==1.10.0 termcolor==1.1.0 vulture==0.8.1 Werkzeug==0.11.4 wheel==0.29.0 - xvfbwrapper==0.2.8 cherrypy==5.0.1 commands = {envpython} scripts/link_pyqt.py --tox {envdir} From 36019c0cab661021e1c6c60807256dfc40541854 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 17 Feb 2016 07:04:25 +0100 Subject: [PATCH 4/7] Split long lines. --- qutebrowser/misc/crashdialog.py | 3 ++- qutebrowser/utils/log.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/qutebrowser/misc/crashdialog.py b/qutebrowser/misc/crashdialog.py index 6dc0c5642..0e794b308 100644 --- a/qutebrowser/misc/crashdialog.py +++ b/qutebrowser/misc/crashdialog.py @@ -241,7 +241,8 @@ class _CrashDialog(QDialog): except Exception: self._crash_info.append(("Launch time", traceback.format_exc())) try: - self._crash_info.append(("Crash time", datetime.datetime.now().ctime())) + self._crash_info.append(("Crash time", + datetime.datetime.now().ctime())) except Exception: self._crash_info.append(("Crash time", traceback.format_exc())) try: diff --git a/qutebrowser/utils/log.py b/qutebrowser/utils/log.py index bacefa2b8..5047a2f61 100644 --- a/qutebrowser/utils/log.py +++ b/qutebrowser/utils/log.py @@ -54,7 +54,8 @@ else: SIMPLE_FMT = '{asctime:8} {levelname}: {message}' EXTENDED_FMT = ('{asctime:8} {levelname:8} {name:10} {module}:{funcName}:' '{lineno} {message}') -SIMPLE_FMT_COLORED = '%(green)s%(asctime)-8s%(reset)s %(log_color)s%(levelname)s%(reset)s: %(message)s' +SIMPLE_FMT_COLORED = ('%(green)s%(asctime)-8s%(reset)s ' + '%(log_color)s%(levelname)s%(reset)s: %(message)s') EXTENDED_FMT_COLORED = ( '%(green)s%(asctime)-8s%(reset)s ' '%(log_color)s%(levelname)-8s%(reset)s ' From 2b2331754df40dd8d730ee72897bbfa61d5544c5 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 17 Feb 2016 07:10:01 +0100 Subject: [PATCH 5/7] Combine launch/crash time into one section. --- qutebrowser/misc/crashdialog.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/qutebrowser/misc/crashdialog.py b/qutebrowser/misc/crashdialog.py index 0e794b308..213c38187 100644 --- a/qutebrowser/misc/crashdialog.py +++ b/qutebrowser/misc/crashdialog.py @@ -237,14 +237,11 @@ class _CrashDialog(QDialog): try: application = QApplication.instance() launch_time = application.launch_time.ctime() - self._crash_info.append(('Launch time', launch_time)) + crash_time = datetime.datetime.now().ctime() + text = 'Launch: {}\nCrash: {}'.format(launch_time, crash_time) + self._crash_info.append(('Timestamps', text)) except Exception: self._crash_info.append(("Launch time", traceback.format_exc())) - try: - self._crash_info.append(("Crash time", - datetime.datetime.now().ctime())) - except Exception: - self._crash_info.append(("Crash time", traceback.format_exc())) try: self._crash_info.append(("Version info", version.version())) except Exception: From 7ba6752020aa2341e515172ec0df97c9ef42115e Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 17 Feb 2016 07:10:14 +0100 Subject: [PATCH 6/7] Regenerate authors. --- README.asciidoc | 1 + 1 file changed, 1 insertion(+) diff --git a/README.asciidoc b/README.asciidoc index a4632f27e..de1fefdaa 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -184,6 +184,7 @@ Contributors, sorted by the number of commits in descending order: * Link * Larry Hynes * Johannes Altmanninger +* avk * Samir Benmendil * Regina Hug * Mathias Fussenegger From 504bf6eb3bfb2ea9c380883f18c5430b7d71b883 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 17 Feb 2016 07:45:36 +0100 Subject: [PATCH 7/7] Remove xvfbwrapper from freeze_tests.py. --- scripts/dev/freeze_tests.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/dev/freeze_tests.py b/scripts/dev/freeze_tests.py index 524dc1999..580033aae 100755 --- a/scripts/dev/freeze_tests.py +++ b/scripts/dev/freeze_tests.py @@ -55,8 +55,7 @@ def get_build_exe_options(): opts = freeze.get_build_exe_options(skip_html=True) opts['includes'] += pytest.freeze_includes() # pylint: disable=no-member opts['includes'] += ['unittest.mock', 'PyQt5.QtTest', 'hypothesis', 'bs4', - 'httpbin', 'jinja2.ext', 'xvfbwrapper', - 'cherrypy.wsgiserver', + 'httpbin', 'jinja2.ext', 'cherrypy.wsgiserver', 'cherrypy.wsgiserver.wsgiserver3', 'pstats'] httpbin_dir = os.path.dirname(httpbin.__file__)