[Pkg-bitcoin-commits] [python-quamash] 93/269: Test configuration changes.

Jonas Smedegaard dr at jones.dk
Fri Nov 24 11:26:19 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 9e9fc99f2cdf77eb48427aa98a8d1fb0a3a808e9
Author: Mark Harviston <mark.harviston at gmail.com>
Date:   Thu Jul 17 12:50:34 2014 -0700

    Test configuration changes.
---
 .travis.yml               |  2 +-
 conftest.py               |  7 +++++++
 coveragerc                | 20 ++++++++++++++++++++
 pytest.ini                |  4 ++--
 tests/test_qeventloop.py  | 10 ++--------
 tests/test_qthreadexec.py | 39 +++++++++++++++++++++++++++++++++++++++
 6 files changed, 71 insertions(+), 11 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 51c4c14..7189f6c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -4,5 +4,5 @@ python:
 before_install:
   - "export DISPLAY=:99.0"
   - "sh -e /etc/init.d/xvfb start"
-install: "pip install pyside"
+install: "pip install pyside pytest-pep8 pytest-cov pytest-flakes"
 script: py.test -s
diff --git a/conftest.py b/conftest.py
new file mode 100644
index 0000000..bcebec0
--- /dev/null
+++ b/conftest.py
@@ -0,0 +1,7 @@
+import sys
+import os.path
+import logging
+sys.path.insert(0, os.path.dirname(__file__))
+logging.basicConfig(
+	level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(name)s - %(message)s')
+
diff --git a/coveragerc b/coveragerc
new file mode 100644
index 0000000..a24f942
--- /dev/null
+++ b/coveragerc
@@ -0,0 +1,20 @@
+[run]
+branch=True
+
+[report]
+# Regexes for lines to exclude from consideration
+exclude_lines =
+    # Have to re-enable the standard pragma
+    pragma: no cover
+
+    # Don't complain about missing debug-only code:
+    def __repr__
+    if self\.debug
+
+    # Don't complain if tests don't hit defensive assertion code:
+    raise AssertionError
+    raise NotImplementedError
+
+    # Don't complain if non-runnable code isn't run:
+    if 0:
+    if __name__ == .__main__.:
\ No newline at end of file
diff --git a/pytest.ini b/pytest.ini
index 429eb53..3a35c7d 100644
--- a/pytest.ini
+++ b/pytest.ini
@@ -1,3 +1,3 @@
 [pytest]
-addopts=--doctest-modules quamash --pep8 tests
-pep8ignore=W191 E501
\ No newline at end of file
+addopts=--doctest-modules quamash --pep8 tests --cov quamash --cov-report html --cov-config coveragerc --flakes
+pep8ignore=W191 E501
diff --git a/tests/test_qeventloop.py b/tests/test_qeventloop.py
index 06ef6b5..91aec4b 100644
--- a/tests/test_qeventloop.py
+++ b/tests/test_qeventloop.py
@@ -1,9 +1,8 @@
 import asyncio
-import os.path
+import locale
 import logging
 import sys
-import locale
-from concurrent.futures import ThreadPoolExecutor, ProcessPoolExecutor
+from concurrent.futures import ThreadPoolExecutor, ProcessPoolExecutor  # noqa
 
 try:
 	from PyQt5.QtWidgets import QApplication
@@ -11,14 +10,9 @@ except ImportError:
 	from PySide.QtGui import QApplication
 import pytest
 
-sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
 import quamash
 
 
-logging.basicConfig(
-	level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(name)s - %(message)s')
-
-
 class _SubprocessProtocol(asyncio.SubprocessProtocol):
 	def __init__(self, *args, **kwds):
 		super(_SubprocessProtocol, self).__init__(*args, **kwds)
diff --git a/tests/test_qthreadexec.py b/tests/test_qthreadexec.py
new file mode 100644
index 0000000..fc03810
--- /dev/null
+++ b/tests/test_qthreadexec.py
@@ -0,0 +1,39 @@
+'''
+try:
+	from PyQt5.QtWidgets import QApplication
+except ImportError:
+	from PySide.QtGui import QApplication
+'''
+
+import pytest
+import quamash
+
+
+ at pytest.fixture
+def executor(request):
+	exe = quamash.QThreadExecutor(5)
+	request.addfinalizer(exe.shutdown)
+	return exe
+
+
+ at pytest.fixture
+def shutdown_executor():
+	exe = quamash.QThreadExecutor(5)
+	exe.shutdown()
+	return exe
+
+
+def test_shutdown_after_shutdown(shutdown_executor):
+	with pytest.raises(RuntimeError):
+		shutdown_executor.shutdown()
+
+
+def test_ctx_after_shutdown(shutdown_executor):
+	with pytest.raises(RuntimeError):
+		with shutdown_executor:
+			pass
+
+
+def test_submit_after_shutdown(shutdown_executor):
+	with pytest.raises(RuntimeError):
+		shutdown_executor.submit(None)

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