[Pkg-bitcoin-commits] [python-quamash] 209/269: Instantiate QApplication once for all (doc)tests

Jonas Smedegaard dr at jones.dk
Fri Nov 24 11:26:34 UTC 2017


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository python-quamash.

commit 5c93eb66a97b6deb3709fd3fca6861b60042ddfb
Author: Arve Knudsen <arve.knudsen at gmail.com>
Date:   Sat Jan 17 22:26:47 2015 +0100

    Instantiate QApplication once for all (doc)tests
---
 conftest.py         | 12 ++++++++++++
 quamash/__init__.py |  9 ++++-----
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/conftest.py b/conftest.py
index 2fdf020..eec9d50 100644
--- a/conftest.py
+++ b/conftest.py
@@ -1,6 +1,7 @@
 import sys
 import os.path
 import logging
+from pytest import fixture
 sys.path.insert(0, os.path.dirname(__file__))
 logging.basicConfig(
 	level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(name)s - %(message)s')
@@ -9,3 +10,14 @@ if os.name == 'nt':
 	collect_ignore = ['quamash/_unix.py']
 else:
 	collect_ignore = ['quamash/_windows.py']
+
+_app = None
+
+
+ at fixture
+def app():
+	from quamash import QApplication
+	global _app
+	if _app is None:
+		_app = QApplication([])
+	return _app
diff --git a/quamash/__init__.py b/quamash/__init__.py
index 381daa5..80d9771 100644
--- a/quamash/__init__.py
+++ b/quamash/__init__.py
@@ -177,10 +177,9 @@ def _easycallback(fn):
 	>>> import asyncio
 	>>>
 	>>> import quamash
-	>>> from quamash import QEventLoop, QtCore, QtGui, QApplication
 	>>> QThread, QObject = quamash.QtCore.QThread, quamash.QtCore.QObject
 	>>>
-	>>> app = QApplication.instance() or QApplication([])
+	>>> app = getfixture('app')
 	>>>
 	>>> global_thread = QThread.currentThread()
 	>>> class MyObject(QObject):
@@ -231,9 +230,9 @@ class QEventLoop(_baseclass):
 	"""
 	Implementation of asyncio event loop that uses the Qt Event loop.
 
-	>>> import quamash, asyncio
-	>>> from quamash import QtCore, QtGui, QApplication
-	>>> app = QApplication.instance() or QApplication([])
+	>>> import asyncio
+	>>>
+	>>> app = getfixture('app')
 	>>>
 	>>> @asyncio.coroutine
 	... def xplusy(x, y):

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-bitcoin/python-quamash.git



More information about the Pkg-bitcoin-commits mailing list