From 9fde38d96af118c9f1b3541b3485352a8a43f4ae Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 13 May 2015 06:31:48 +0200 Subject: [PATCH] Reset CaretBrowsingEnabled to original value. --- tests/javascript/position_caret/test_position_caret.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/javascript/position_caret/test_position_caret.py b/tests/javascript/position_caret/test_position_caret.py index 0fbf4e3f1..6fdfef11e 100644 --- a/tests/javascript/position_caret/test_position_caret.py +++ b/tests/javascript/position_caret/test_position_caret.py @@ -26,11 +26,14 @@ from PyQt5.QtWebKit import QWebSettings from PyQt5.QtWebKitWidgets import QWebPage -@pytest.fixture(autouse=True) +@pytest.yield_fixture(autouse=True) def enable_caret_browsing(): """Fixture to enable caret browsing globally.""" - QWebSettings.globalSettings().setAttribute( - QWebSettings.CaretBrowsingEnabled, True) + settings = QWebSettings.globalSettings() + old_value = settings.testAttribute(QWebSettings.CaretBrowsingEnabled) + settings.setAttribute(QWebSettings.CaretBrowsingEnabled, True) + yield + settings.setAttribute(QWebSettings.CaretBrowsingEnabled, old_value) class CaretTester: