From d47409b2635aa5d1894bd66162b2605280a51ef7 Mon Sep 17 00:00:00 2001 From: Giulio Ungaretti Date: Tue, 26 Jul 2016 00:00:49 +0200 Subject: [PATCH 1/4] Fix: Check multiprocessing method. Allow for unittest, generally a good idea to check for all the allowed methods. See #282. --- qcodes/tests/test_loop.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/qcodes/tests/test_loop.py b/qcodes/tests/test_loop.py index 869025fee71..0d18b80cffe 100644 --- a/qcodes/tests/test_loop.py +++ b/qcodes/tests/test_loop.py @@ -94,7 +94,16 @@ def test_local_instrument(self): c1 = gates_local.chan1 loop_local = Loop(c1[1:5:1], 0.001).each(c1) - with self.assertRaises(RuntimeError): + # if spawn, pickle will happen + if mp.get_start_method() == "spawn": + with self.assertRaises(RuntimeError): + loop_local.run(location=self.location, quiet=True) + # allow for *nix + # TODO(giulioungaretti) see what happens ? + # what is the expected beavhiour ? + # The RunimError will never be raised here, as the forkmethod + # won't try to pickle anything at all. + else: loop_local.run(location=self.location, quiet=True) data = loop_local.run(location=self.location2, background=False, From 3bcd331c7f59a1eb74b0353f97fc280282bfbda9 Mon Sep 17 00:00:00 2001 From: Giulio Ungaretti Date: Tue, 26 Jul 2016 09:26:51 +0200 Subject: [PATCH 2/4] fix: Mo 'coverage. --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index f3036ea8829..0791ea91c9e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,6 +25,9 @@ after_success: - cd qcodes - coverage xml - python-codacy-coverage -r coverage.xml + # codecvo + - bash <(curl -s https://codecov.io/bash) -t c3b231db-2db3-4560-a477-6edcf4cf5ad1 + # # build the docs, one dir up - cd ../ - make -f docs/Makefile gh-pages From 13f3d2ed057fd742f0d7e453fd1009d59f69286f Mon Sep 17 00:00:00 2001 From: Giulio Ungaretti Date: Tue, 26 Jul 2016 10:48:18 +0200 Subject: [PATCH 3/4] fix: Catch the correct exception --- qcodes/tests/test_instrument_server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qcodes/tests/test_instrument_server.py b/qcodes/tests/test_instrument_server.py index 3dc298ace79..36e30178dcf 100644 --- a/qcodes/tests/test_instrument_server.py +++ b/qcodes/tests/test_instrument_server.py @@ -123,7 +123,7 @@ def test_normal(self): with LogCapture() as logs: TimedInstrumentServer(self.query_queue, self.response_queue, extras) - except: + except TypeError: from traceback import format_exc print(format_exc()) From 2fc2900f0392996131b448e9c58bf396b61a3fa7 Mon Sep 17 00:00:00 2001 From: Giulio Ungaretti Date: Thu, 28 Jul 2016 11:08:47 +0200 Subject: [PATCH 4/4] fix: Print error instead of failing. --- qcodes/tests/test_instrument_server.py | 6 +++--- qcodes/tests/test_loop.py | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/qcodes/tests/test_instrument_server.py b/qcodes/tests/test_instrument_server.py index 36e30178dcf..38697854e3c 100644 --- a/qcodes/tests/test_instrument_server.py +++ b/qcodes/tests/test_instrument_server.py @@ -10,11 +10,11 @@ def schedule(queries, query_queue): - ''' - queries is a sequence of (delay, args) + """ + queries is a sequence of (delay, args) query_queue is a queue to push these queries to, with each one waiting its delay after sending the previous one - ''' + """ for delay, args in queries: time.sleep(delay) query_queue.put(args) diff --git a/qcodes/tests/test_loop.py b/qcodes/tests/test_loop.py index 0d18b80cffe..3f5f5e4ae7f 100644 --- a/qcodes/tests/test_loop.py +++ b/qcodes/tests/test_loop.py @@ -1,9 +1,10 @@ -from unittest import TestCase -from unittest.mock import patch -import time from datetime import datetime +import logging import multiprocessing as mp import numpy as np +import time +from unittest import TestCase +from unittest.mock import patch from qcodes.loops import (Loop, MP_NAME, get_bg, halt_bg, ActiveLoop, _DebugInterrupt) @@ -104,6 +105,7 @@ def test_local_instrument(self): # The RunimError will never be raised here, as the forkmethod # won't try to pickle anything at all. else: + logging.error("this should not be allowed, but for now we let it be") loop_local.run(location=self.location, quiet=True) data = loop_local.run(location=self.location2, background=False,