[Pkg-bitcoin-commits] [python-quamash] 211/269: Share a fixture between doctest & test_qeventloop.py
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 4f51bdb395b3b5d9b48e557f0e0e48732534b452
Author: Mark Harviston <mark.harviston at gmail.com>
Date: Sun Jan 18 01:31:14 2015 -0800
Share a fixture between doctest & test_qeventloop.py
Sharing a fixture between doctests and test_qeventloop.py allows running
the tests out-of-order.
Before the doctests would create the fixture and then
QApplication.instance() would retrieve the application instance.
Now, they share a fixture marked scope="session" which will remain alive
for the entire scope.
Downside is now test_qeventloop.py depends on conftest.py
---
conftest.py | 11 +++--------
quamash/__init__.py | 4 ++--
tests/test_qeventloop.py | 5 -----
3 files changed, 5 insertions(+), 15 deletions(-)
diff --git a/conftest.py b/conftest.py
index eec9d50..e34e139 100644
--- a/conftest.py
+++ b/conftest.py
@@ -11,13 +11,8 @@ if os.name == 'nt':
else:
collect_ignore = ['quamash/_windows.py']
-_app = None
-
- at fixture
-def app():
+ at fixture(scope='session')
+def application():
from quamash import QApplication
- global _app
- if _app is None:
- _app = QApplication([])
- return _app
+ return QApplication([])
diff --git a/quamash/__init__.py b/quamash/__init__.py
index 80d9771..56fc8b0 100644
--- a/quamash/__init__.py
+++ b/quamash/__init__.py
@@ -179,7 +179,7 @@ def _easycallback(fn):
>>> import quamash
>>> QThread, QObject = quamash.QtCore.QThread, quamash.QtCore.QObject
>>>
- >>> app = getfixture('app')
+ >>> app = getfixture('application')
>>>
>>> global_thread = QThread.currentThread()
>>> class MyObject(QObject):
@@ -232,7 +232,7 @@ class QEventLoop(_baseclass):
>>> import asyncio
>>>
- >>> app = getfixture('app')
+ >>> app = getfixture('application')
>>>
>>> @asyncio.coroutine
... def xplusy(x, y):
diff --git a/tests/test_qeventloop.py b/tests/test_qeventloop.py
index 520744b..08fa43a 100644
--- a/tests/test_qeventloop.py
+++ b/tests/test_qeventloop.py
@@ -30,11 +30,6 @@ class _SubprocessProtocol(asyncio.SubprocessProtocol):
asyncio.get_event_loop().stop()
- at pytest.fixture(scope='session')
-def application():
- return quamash.QApplication.instance() or quamash.QApplication([])
-
-
@pytest.fixture
def loop(request, application):
lp = quamash.QEventLoop(application)
--
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