[Pkg-bitcoin-commits] [python-quamash] 46/269: Only create QApplication once for all tests

Jonas Smedegaard dr at jones.dk
Fri Nov 24 11:26:15 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 cf5f906b6ee47e9ee0cd75c81bb368f3f76e2723
Author: Arve Knudsen <arve.knudsen at gmail.com>
Date:   Thu Jul 3 15:47:48 2014 +0200

    Only create QApplication once for all tests
---
 tests/test_qeventloop.py | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/tests/test_qeventloop.py b/tests/test_qeventloop.py
index 2c47a6e..cdaa21a 100644
--- a/tests/test_qeventloop.py
+++ b/tests/test_qeventloop.py
@@ -31,10 +31,16 @@ class _SubprocessProtocol(asyncio.SubprocessProtocol):
 		asyncio.get_event_loop().stop()
 
 
- at pytest.fixture
-def loop(request):
+
+ at pytest.fixture(scope='session')
+def application():
 	app = QApplication([])
-	lp = quamash.QEventLoop(app)
+	return app
+
+
+ at pytest.fixture
+def loop(request, application):
+	lp = quamash.QEventLoop(application)
 	asyncio.set_event_loop(lp)
 
 	def fin():
@@ -70,10 +76,8 @@ class TestQEventLoop:
 		assert transport.get_returncode() == 0
 		assert protocol.received_stdout == 'Hello async world!'
 
-	def test_can_function_as_context_manager(self):
-		app = QApplication([])
-
-		with quamash.QEventLoop(app) as loop:
+	def test_can_function_as_context_manager(self, application):
+		with quamash.QEventLoop(application) as loop:
 			assert isinstance(loop, quamash.QEventLoop)
 			loop.call_soon(loop.stop)
 			loop.run_forever()

-- 
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