From e8ddd9397dc3b781bc7d37b2bf2a88e1a3b5ac72 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 13 Apr 2015 22:34:30 +0200 Subject: [PATCH] Use a single QNetworkAccessManager per session. --- tests/conftest.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 865cb22f9..a32e9cfd0 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -49,15 +49,23 @@ def unicode_encode_err(): 'fake exception') # reason +@pytest.fixture(scope='session') +def qnam(): + """Session-wide QNetworkAccessManager.""" + from PyQt5.QtNetwork import QNetworkAccessManager + nam = QNetworkAccessManager() + nam.setNetworkAccessible(QNetworkAccessManager.NotAccessible) + return nam + + @pytest.fixture -def webpage(): +def webpage(qnam): """Get a new QWebPage object.""" from PyQt5.QtWebKitWidgets import QWebPage - from PyQt5.QtNetwork import QNetworkAccessManager page = QWebPage() - nam = page.networkAccessManager() - nam.setNetworkAccessible(QNetworkAccessManager.NotAccessible) + page.networkAccessManager().deleteLater() + page.setNetworkAccessManager(qnam) return page