From 3d858acc3075fe4968d6dc4aa2af679746f66b7f Mon Sep 17 00:00:00 2001 From: AUC Hardal Date: Wed, 10 Jun 2020 11:40:36 +0200 Subject: [PATCH 01/32] Run tests in parallel --- pytest.ini | 6 +++++- test_requirements.txt | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pytest.ini b/pytest.ini index 9bd10d17bb7..a0784901dae 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,2 +1,6 @@ [pytest] -junit_family=legacy \ No newline at end of file +junit_family=legacy + +addopts = + -n auto + --dist=loadfile \ No newline at end of file diff --git a/test_requirements.txt b/test_requirements.txt index 34111793984..9c1a4058de5 100644 --- a/test_requirements.txt +++ b/test_requirements.txt @@ -2,6 +2,7 @@ coverage!=4.5.0 pytest-cov pytest pytest-rerunfailures +pytest-xdist codacy-coverage hypothesis<5.6.0 # large number of warnings due to change in 5.6.0 https://hypothesis.readthedocs.io/en/latest/changes.html#v5-6-0 mypy==0.780 From 2aa86ca8223cdc04df8839caa3b2c7f39c60b92e Mon Sep 17 00:00:00 2001 From: AUC Hardal Date: Wed, 10 Jun 2020 11:57:47 +0200 Subject: [PATCH 02/32] Try with 4 cores --- pytest.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pytest.ini b/pytest.ini index a0784901dae..f05073f35d7 100644 --- a/pytest.ini +++ b/pytest.ini @@ -2,5 +2,5 @@ junit_family=legacy addopts = - -n auto + -n 4 --dist=loadfile \ No newline at end of file From 1f4ca908ab3011cb2c3c3c747f0e6806b4647cc6 Mon Sep 17 00:00:00 2001 From: AUC Hardal Date: Wed, 10 Jun 2020 12:13:47 +0200 Subject: [PATCH 03/32] Rename math to math_utils --- pytest.ini | 2 +- qcodes/{math => math_utils}/__init__.py | 0 qcodes/{math => math_utils}/field_vector.py | 0 3 files changed, 1 insertion(+), 1 deletion(-) rename qcodes/{math => math_utils}/__init__.py (100%) rename qcodes/{math => math_utils}/field_vector.py (100%) diff --git a/pytest.ini b/pytest.ini index f05073f35d7..a0784901dae 100644 --- a/pytest.ini +++ b/pytest.ini @@ -2,5 +2,5 @@ junit_family=legacy addopts = - -n 4 + -n auto --dist=loadfile \ No newline at end of file diff --git a/qcodes/math/__init__.py b/qcodes/math_utils/__init__.py similarity index 100% rename from qcodes/math/__init__.py rename to qcodes/math_utils/__init__.py diff --git a/qcodes/math/field_vector.py b/qcodes/math_utils/field_vector.py similarity index 100% rename from qcodes/math/field_vector.py rename to qcodes/math_utils/field_vector.py From f536b2f9c505c544e13376fa5e082cb7c516665e Mon Sep 17 00:00:00 2001 From: AUC Hardal Date: Wed, 10 Jun 2020 12:30:34 +0200 Subject: [PATCH 04/32] Fix the paths --- qcodes/instrument_drivers/american_magnetics/AMI430.py | 2 +- qcodes/tests/drivers/test_MercuryiPS.py | 2 +- qcodes/tests/drivers/test_ami430.py | 2 +- qcodes/tests/test_field_vector.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/qcodes/instrument_drivers/american_magnetics/AMI430.py b/qcodes/instrument_drivers/american_magnetics/AMI430.py index 409f89b2680..79401955cbd 100644 --- a/qcodes/instrument_drivers/american_magnetics/AMI430.py +++ b/qcodes/instrument_drivers/american_magnetics/AMI430.py @@ -9,7 +9,7 @@ from qcodes import Instrument, IPInstrument, InstrumentChannel from qcodes.utils.deprecate import deprecate -from qcodes.math.field_vector import FieldVector +from qcodes.math_utils.field_vector import FieldVector from qcodes.utils.validators import Bool, Numbers, Ints, Anything log = logging.getLogger(__name__) diff --git a/qcodes/tests/drivers/test_MercuryiPS.py b/qcodes/tests/drivers/test_MercuryiPS.py index 61a6f8ba6fc..c778d12fe41 100644 --- a/qcodes/tests/drivers/test_MercuryiPS.py +++ b/qcodes/tests/drivers/test_MercuryiPS.py @@ -6,7 +6,7 @@ from qcodes.instrument_drivers.oxford.MercuryiPS_VISA import MercuryiPS import qcodes.instrument.sims as sims -from qcodes.math.field_vector import FieldVector +from qcodes.math_utils.field_vector import FieldVector visalib = sims.__file__.replace('__init__.py', 'MercuryiPS.yaml@sim') diff --git a/qcodes/tests/drivers/test_ami430.py b/qcodes/tests/drivers/test_ami430.py index a0af49fd1b7..8a8dbb413e7 100644 --- a/qcodes/tests/drivers/test_ami430.py +++ b/qcodes/tests/drivers/test_ami430.py @@ -14,7 +14,7 @@ from qcodes.instrument_drivers.american_magnetics.AMI430 import AMI430_3D, \ AMI430Warning from qcodes.instrument.ip_to_visa import AMI430_VISA -from qcodes.math.field_vector import FieldVector +from qcodes.math_utils.field_vector import FieldVector from qcodes.utils.types import numpy_concrete_ints, numpy_concrete_floats, \ numpy_non_concrete_ints_instantiable, \ numpy_non_concrete_floats_instantiable diff --git a/qcodes/tests/test_field_vector.py b/qcodes/tests/test_field_vector.py index b49773c000d..ff12dc1bf25 100644 --- a/qcodes/tests/test_field_vector.py +++ b/qcodes/tests/test_field_vector.py @@ -8,7 +8,7 @@ from hypothesis.strategies import floats from hypothesis.strategies import tuples -from qcodes.math.field_vector import FieldVector +from qcodes.math_utils.field_vector import FieldVector from qcodes.utils.helpers import NumpyJSONEncoder random_coordinates = { From c022963d415a83552e3901b63c8fc64a810ed542 Mon Sep 17 00:00:00 2001 From: AUC Hardal Date: Wed, 10 Jun 2020 12:41:41 +0200 Subject: [PATCH 05/32] Fix the import --- qcodes/instrument_drivers/oxford/MercuryiPS_VISA.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qcodes/instrument_drivers/oxford/MercuryiPS_VISA.py b/qcodes/instrument_drivers/oxford/MercuryiPS_VISA.py index e1199fbf2f0..4c2be1b396e 100644 --- a/qcodes/instrument_drivers/oxford/MercuryiPS_VISA.py +++ b/qcodes/instrument_drivers/oxford/MercuryiPS_VISA.py @@ -8,7 +8,7 @@ from qcodes.instrument.channel import InstrumentChannel from qcodes.instrument.visa import VisaInstrument -from qcodes.math.field_vector import FieldVector +from qcodes.math_utils.field_vector import FieldVector log = logging.getLogger(__name__) visalog = logging.getLogger('qcodes.instrument.visa') From 37bcd9ae73fa9b06262c2a96c50c3383f46426d7 Mon Sep 17 00:00:00 2001 From: AUC Hardal Date: Wed, 10 Jun 2020 13:30:19 +0200 Subject: [PATCH 06/32] Fix import in examples --- docs/examples/driver_examples/Qcodes example with AMI430.ipynb | 2 +- .../Qcodes example with Oxford Mercury iPS.ipynb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/examples/driver_examples/Qcodes example with AMI430.ipynb b/docs/examples/driver_examples/Qcodes example with AMI430.ipynb index a8df4636c09..64fc9017ed8 100644 --- a/docs/examples/driver_examples/Qcodes example with AMI430.ipynb +++ b/docs/examples/driver_examples/Qcodes example with AMI430.ipynb @@ -53,7 +53,7 @@ "import matplotlib.pyplot as plt \n", "\n", "from qcodes.instrument_drivers.american_magnetics.AMI430 import AMI430, AMI430_3D\n", - "from qcodes.math.field_vector import FieldVector" + "from qcodes.math_utils.field_vector import FieldVector" ] }, { diff --git a/docs/examples/driver_examples/Qcodes example with Oxford Mercury iPS.ipynb b/docs/examples/driver_examples/Qcodes example with Oxford Mercury iPS.ipynb index 17ce2bac04c..577bb15009d 100644 --- a/docs/examples/driver_examples/Qcodes example with Oxford Mercury iPS.ipynb +++ b/docs/examples/driver_examples/Qcodes example with Oxford Mercury iPS.ipynb @@ -506,7 +506,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.2" + "version": "3.7.5" }, "nbsphinx": { "execute": "never" From 61425b395f311507f2bc951ee546f2cd93ee2347 Mon Sep 17 00:00:00 2001 From: AUC Hardal Date: Wed, 10 Jun 2020 14:29:18 +0200 Subject: [PATCH 07/32] Fix api docs --- docs/api/index.rst | 2 +- docs/api/{math => math_utils}/field_vector.rst | 0 docs/api/{math => math_utils}/index.rst | 6 +++--- 3 files changed, 4 insertions(+), 4 deletions(-) rename docs/api/{math => math_utils}/field_vector.rst (100%) rename docs/api/{math => math_utils}/index.rst (56%) diff --git a/docs/api/index.rst b/docs/api/index.rst index 4f41a2e95e0..b58006ec629 100644 --- a/docs/api/index.rst +++ b/docs/api/index.rst @@ -21,7 +21,7 @@ QCoDeS API instrument/index parameters/index logger/index - math/index + math_utils/index monitor/index station utils/index diff --git a/docs/api/math/field_vector.rst b/docs/api/math_utils/field_vector.rst similarity index 100% rename from docs/api/math/field_vector.rst rename to docs/api/math_utils/field_vector.rst diff --git a/docs/api/math/index.rst b/docs/api/math_utils/index.rst similarity index 56% rename from docs/api/math/index.rst rename to docs/api/math_utils/index.rst index f36e7a53471..eae2c953a77 100644 --- a/docs/api/math/index.rst +++ b/docs/api/math_utils/index.rst @@ -5,11 +5,11 @@ qcodes.math .. autosummary:: - qcodes.math - qcodes.math.field_vector + qcodes.math_utils + qcodes.math_utils.field_vector -.. automodule:: qcodes.math +.. automodule:: qcodes.math_utils .. toctree:: From be0494b1271dd29598a60846ad8f2b5d656e4ddd Mon Sep 17 00:00:00 2001 From: AUC Hardal Date: Wed, 10 Jun 2020 14:50:02 +0200 Subject: [PATCH 08/32] Fix docs --- docs/api/math_utils/field_vector.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api/math_utils/field_vector.rst b/docs/api/math_utils/field_vector.rst index 01569bb3b30..c5528f637aa 100644 --- a/docs/api/math_utils/field_vector.rst +++ b/docs/api/math_utils/field_vector.rst @@ -1,5 +1,5 @@ qcodes.math.field_vector ------------------------ -.. automodule:: qcodes.math.field_vector +.. automodule:: qcodes.math_utils.field_vector :members: \ No newline at end of file From 99bde04e360734b9fcd9a6bc80aa957a03221a61 Mon Sep 17 00:00:00 2001 From: AUC Hardal Date: Thu, 11 Jun 2020 13:53:31 +0200 Subject: [PATCH 09/32] Remove log.debug from data_set.py --- qcodes/dataset/data_set.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/qcodes/dataset/data_set.py b/qcodes/dataset/data_set.py index 507492363b8..16af1439cce 100644 --- a/qcodes/dataset/data_set.py +++ b/qcodes/dataset/data_set.py @@ -172,8 +172,6 @@ def _exhaust_queue(queue: Queue) -> List: def _call_callback_on_queue_data(self) -> None: result_list = self._exhaust_queue(self.data_queue) self.callback(result_list, self._data_set_len, self.state) - self.log.debug(f"{self.callback} called with " - f"result_list: {result_list}.") def _loop(self) -> None: while True: From f0e99002db42822991976b68cf880ecb2910c743 Mon Sep 17 00:00:00 2001 From: AUC Hardal Date: Thu, 11 Jun 2020 14:51:49 +0200 Subject: [PATCH 10/32] Remove one more log from data_set.py --- qcodes/dataset/data_set.py | 1 - 1 file changed, 1 deletion(-) diff --git a/qcodes/dataset/data_set.py b/qcodes/dataset/data_set.py index 16af1439cce..2d7fa7abcdf 100644 --- a/qcodes/dataset/data_set.py +++ b/qcodes/dataset/data_set.py @@ -190,7 +190,6 @@ def _loop(self) -> None: break def done_callback(self) -> None: - self.log.debug("Done callback") self._call_callback_on_queue_data() def schedule_stop(self) -> None: From 1fbd772558faf2f5016205a2e3fc5cd1e2c1c0d5 Mon Sep 17 00:00:00 2001 From: AUC Hardal Date: Mon, 15 Jun 2020 11:20:06 +0200 Subject: [PATCH 11/32] Fix newly emerged location errors --- qcodes/tests/test_data.py | 16 +++++++++++++--- qcodes/tests/test_format.py | 6 +++++- qcodes/tests/test_measure.py | 6 +++++- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/qcodes/tests/test_data.py b/qcodes/tests/test_data.py index 9fe0caedee9..25dc886c15a 100644 --- a/qcodes/tests/test_data.py +++ b/qcodes/tests/test_data.py @@ -4,6 +4,7 @@ import pickle import logging +from qcodes.data.location import FormatLocation from qcodes.data.data_array import DataArray from qcodes.data.io import DiskIO from qcodes.data.data_set import load_data, new_data, DataSet @@ -446,12 +447,18 @@ def test_write_copy(self): def test_pickle_dataset(self): # Test pickling of DataSet object # If the data_manager is set to None, then the object should pickle. - m = DataSet2D() + loc_fmt = 'data/{date}/#{counter}_{name}_{date}_{time}' + rcd = {'name': 'test_pickle_dataset'} + loc_provider = FormatLocation(fmt=loc_fmt, record=rcd) + m = DataSet2D(location=loc_provider) pickle.dumps(m) def test_default_parameter(self): + loc_fmt = 'data/{date}/#{counter}_{name}_{date}_{time}' + rcd = {'name': 'test_default_parameter'} + loc_provider = FormatLocation(fmt=loc_fmt, record=rcd) # Test whether the default_array function works - m = DataSet2D() + m = DataSet2D(location=loc_provider) # test we can run with default arguments name = m.default_parameter_name() @@ -560,7 +567,10 @@ def test_complete(self): self.assertEqual(log_index, len(logs), logs) def test_remove_array(self): - m = DataSet2D() + loc_fmt = 'data/{date}/#{counter}_{name}_{date}_{time}' + rcd = {'name': 'test_remove_array'} + loc_provider = FormatLocation(fmt=loc_fmt, record=rcd) + m = DataSet2D(location=loc_provider) m.remove_array('z') _ = m.__repr__() self.assertFalse('z' in m.arrays) diff --git a/qcodes/tests/test_format.py b/qcodes/tests/test_format.py index 9922c42f0f7..8f75b1af050 100644 --- a/qcodes/tests/test_format.py +++ b/qcodes/tests/test_format.py @@ -1,6 +1,7 @@ from unittest import TestCase import os +from qcodes.data.location import FormatLocation from qcodes.data.format import Formatter from qcodes.data.gnuplot_format import GNUPlotFormat @@ -24,7 +25,10 @@ def tearDown(self): def test_overridable_methods(self): formatter = Formatter() - data = DataSet1D() + loc_fmt = 'data/{date}/#{counter}_{name}_{date}_{time}' + rcd = {'name': 'test_overridable_methods'} + loc_provider = FormatLocation(fmt=loc_fmt, record=rcd) + data = DataSet1D(location=loc_provider) with self.assertRaises(NotImplementedError): formatter.write(data, data.io, data.location) diff --git a/qcodes/tests/test_measure.py b/qcodes/tests/test_measure.py index ef8c8a94ba1..bcbc2a550f7 100644 --- a/qcodes/tests/test_measure.py +++ b/qcodes/tests/test_measure.py @@ -1,6 +1,7 @@ from unittest import TestCase from datetime import datetime +from qcodes.data.location import FormatLocation from qcodes.instrument.parameter import Parameter from qcodes.measure import Measure @@ -55,7 +56,10 @@ def setUp(self): def test_metadata(self): - c = Measure(self.p1).run() + loc_fmt = 'data/{date}/#{counter}_{name}_{date}_{time}' + rcd = {'name': 'test_metadata'} + loc_provider = FormatLocation(fmt=loc_fmt, record=rcd) + c = Measure(self.p1).run(location=loc_provider) self.assertEqual(c.metadata['arrays']['this']['unit'], 'this unit') self.assertEqual(c.metadata['arrays']['this']['name'], 'this') self.assertEqual(c.metadata['arrays']['this']['label'], 'this label') From b6f560af11e4cd45a4b6a7a242a0db98de861b7c Mon Sep 17 00:00:00 2001 From: AUC Hardal Date: Mon, 15 Jun 2020 11:21:38 +0200 Subject: [PATCH 12/32] Fix lonf lines --- qcodes/tests/test_measure.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/qcodes/tests/test_measure.py b/qcodes/tests/test_measure.py index bcbc2a550f7..2ed6b1d5574 100644 --- a/qcodes/tests/test_measure.py +++ b/qcodes/tests/test_measure.py @@ -74,9 +74,14 @@ def test_metadata(self): self.assertEqual(c.metadata['arrays']['that']['shape'], (5,)) assert_array_equal(c.that.ndarray, np.ones(5)) - self.assertEqual(c.metadata['arrays']['this_setpoint_set']['unit'], 'this setpointunit') - self.assertEqual(c.metadata['arrays']['this_setpoint_set']['name'], 'this_setpoint') - self.assertEqual(c.metadata['arrays']['this_setpoint_set']['label'], 'this setpoint') - self.assertEqual(c.metadata['arrays']['this_setpoint_set']['is_setpoint'], True) - self.assertEqual(c.metadata['arrays']['this_setpoint_set']['shape'], (5,)) + self.assertEqual(c.metadata['arrays']['this_setpoint_set']['unit'], + 'this setpointunit') + self.assertEqual(c.metadata['arrays']['this_setpoint_set']['name'], + 'this_setpoint') + self.assertEqual(c.metadata['arrays']['this_setpoint_set']['label'], + 'this setpoint') + self.assertEqual(c.metadata['arrays']['this_setpoint_set'] + ['is_setpoint'], True) + self.assertEqual(c.metadata['arrays']['this_setpoint_set']['shape'], + (5,)) assert_array_equal(c.this_setpoint_set.ndarray, np.linspace(5, 9, 5)) From 4b1c8cb2d16051acba421b2d3af185e3bf91498b Mon Sep 17 00:00:00 2001 From: AUC Hardal Date: Mon, 15 Jun 2020 13:49:10 +0200 Subject: [PATCH 13/32] Try with load option and fix 2 workers --- pytest.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pytest.ini b/pytest.ini index a0784901dae..3c6d635087e 100644 --- a/pytest.ini +++ b/pytest.ini @@ -2,5 +2,5 @@ junit_family=legacy addopts = - -n auto - --dist=loadfile \ No newline at end of file + -n 2 + --dist=load \ No newline at end of file From b16fc56432731638f99975cf34d794896d074467 Mon Sep 17 00:00:00 2001 From: AUC Hardal Date: Mon, 15 Jun 2020 14:37:46 +0200 Subject: [PATCH 14/32] try loadfile with 2 cores fixed --- pytest.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pytest.ini b/pytest.ini index 3c6d635087e..12aa50764c9 100644 --- a/pytest.ini +++ b/pytest.ini @@ -3,4 +3,4 @@ junit_family=legacy addopts = -n 2 - --dist=load \ No newline at end of file + --dist=loadfile \ No newline at end of file From 82caccb15342f8af7eec253bc2d917b53da121fb Mon Sep 17 00:00:00 2001 From: AUC Hardal Date: Mon, 15 Jun 2020 14:54:40 +0200 Subject: [PATCH 15/32] Use load --- pytest.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pytest.ini b/pytest.ini index 12aa50764c9..3c6d635087e 100644 --- a/pytest.ini +++ b/pytest.ini @@ -3,4 +3,4 @@ junit_family=legacy addopts = -n 2 - --dist=loadfile \ No newline at end of file + --dist=load \ No newline at end of file From 66d6b0eb497012e5867ce1c26255119cda975508 Mon Sep 17 00:00:00 2001 From: AUC Hardal Date: Mon, 15 Jun 2020 15:24:00 +0200 Subject: [PATCH 16/32] Skip the test only in win --- qcodes/tests/dataset/test_measurement_context_manager.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/qcodes/tests/dataset/test_measurement_context_manager.py b/qcodes/tests/dataset/test_measurement_context_manager.py index 859c790a340..7adc7b56fb7 100644 --- a/qcodes/tests/dataset/test_measurement_context_manager.py +++ b/qcodes/tests/dataset/test_measurement_context_manager.py @@ -1,5 +1,6 @@ import re import os +import sys from time import sleep import json import logging @@ -725,6 +726,7 @@ def collect_x_vals(results, length, state): assert collected_x_vals == given_x_vals +@pytest.mark.skipif(sys.platform.startswith("win"), reason="For xdist to pass") @pytest.mark.flaky(reruns=5) @settings(deadline=None, max_examples=25) @given(N=hst.integers(min_value=2000, max_value=3000)) From 2c89c5337eef3fbc627ea2698bb1218e210581fd Mon Sep 17 00:00:00 2001 From: AUC Hardal Date: Mon, 15 Jun 2020 15:40:23 +0200 Subject: [PATCH 17/32] use loadfile --- pytest.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pytest.ini b/pytest.ini index 3c6d635087e..12aa50764c9 100644 --- a/pytest.ini +++ b/pytest.ini @@ -3,4 +3,4 @@ junit_family=legacy addopts = -n 2 - --dist=load \ No newline at end of file + --dist=loadfile \ No newline at end of file From d73306195ab8816f26e1d177eaffaa1662960bce Mon Sep 17 00:00:00 2001 From: AUC Hardal Date: Tue, 16 Jun 2020 13:56:21 +0200 Subject: [PATCH 18/32] Use markers to select serial runs --- azure-pipelines.yml | 1 + qcodes/tests/conftest.py | 26 +++++++++++++++++++ .../test_measurement_context_manager.py | 3 +-- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index c34c8ca007e..daff82a614a 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -96,6 +96,7 @@ jobs: source activate qcodes && cd qcodes && pytest --junitxml=test-results.xml --cov=qcodes --cov-report=xml --cov-config=.coveragerc + pytest -n 0 -E serial --junitxml=test-results.xml --cov=qcodes --cov-report=xml --cov-config=.coveragerc displayName: "Pytest on Windows" condition: and(succeededOrFailed(), eq( variables['Agent.OS'], 'Windows_NT' )) - bash: | diff --git a/qcodes/tests/conftest.py b/qcodes/tests/conftest.py index 9b3a0d20998..5be225cb183 100644 --- a/qcodes/tests/conftest.py +++ b/qcodes/tests/conftest.py @@ -43,3 +43,29 @@ def disable_config_subscriber(): yield finally: qc.config.subscription.default_subscribers = original_state + + +def pytest_addoption(parser): + parser.addoption( + "-E", + action="store", + metavar="NAME", + help="only run tests marked with 'env(NAME)' to run in environment NAME.", + ) + + +def pytest_configure(config): + config.addinivalue_line( + "markers", "env(name): mark test to run only on named environment" + ) + + +def pytest_runtest_setup(item): + env_names = [mark.args[0] for mark in item.iter_markers(name="env")] + if env_names: + env_from_option = item.config.getoption("-E") + if env_from_option not in env_names: + pytest.skip( + f"Not running in {env_names!r} environment(s). " + f"Use '-E' command line option to run this test." + ) diff --git a/qcodes/tests/dataset/test_measurement_context_manager.py b/qcodes/tests/dataset/test_measurement_context_manager.py index 7adc7b56fb7..66870998855 100644 --- a/qcodes/tests/dataset/test_measurement_context_manager.py +++ b/qcodes/tests/dataset/test_measurement_context_manager.py @@ -1,6 +1,5 @@ import re import os -import sys from time import sleep import json import logging @@ -726,7 +725,7 @@ def collect_x_vals(results, length, state): assert collected_x_vals == given_x_vals -@pytest.mark.skipif(sys.platform.startswith("win"), reason="For xdist to pass") +@pytest.mark.env("serial") @pytest.mark.flaky(reruns=5) @settings(deadline=None, max_examples=25) @given(N=hst.integers(min_value=2000, max_value=3000)) From 4475fa53b9d22c5dfa0b7e1d09ce8f66cafa1d9e Mon Sep 17 00:00:00 2001 From: AUC Hardal Date: Tue, 16 Jun 2020 14:04:25 +0200 Subject: [PATCH 19/32] Fix conftest --- qcodes/tests/conftest.py | 47 ++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 26 deletions(-) diff --git a/qcodes/tests/conftest.py b/qcodes/tests/conftest.py index 5be225cb183..e71eabb78b3 100644 --- a/qcodes/tests/conftest.py +++ b/qcodes/tests/conftest.py @@ -5,6 +5,18 @@ def pytest_configure(config): config.addinivalue_line("markers", "win32: tests that only run under windows") + config.addinivalue_line( + "markers", "env(name): mark test to run only on named environment" + ) + + +def pytest_addoption(parser): + parser.addoption( + "-E", + action="store", + metavar="NAME", + help="only run tests marked with 'env(NAME)' to run in environment NAME.", + ) def pytest_runtest_setup(item): @@ -13,6 +25,15 @@ def pytest_runtest_setup(item): if supported_platforms and sys.platform not in supported_platforms: pytest.skip(f"cannot run on platform {sys.platform}") + env_names = [mark.args[0] for mark in item.iter_markers(name="env")] + if env_names: + env_from_option = item.config.getoption("-E") + if env_from_option not in env_names: + pytest.skip( + f"Not running in {env_names!r} environment(s). " + f"Use '-E' command line option to run this test." + ) + @pytest.fixture(scope="session", autouse=True) def disable_telemetry(): @@ -43,29 +64,3 @@ def disable_config_subscriber(): yield finally: qc.config.subscription.default_subscribers = original_state - - -def pytest_addoption(parser): - parser.addoption( - "-E", - action="store", - metavar="NAME", - help="only run tests marked with 'env(NAME)' to run in environment NAME.", - ) - - -def pytest_configure(config): - config.addinivalue_line( - "markers", "env(name): mark test to run only on named environment" - ) - - -def pytest_runtest_setup(item): - env_names = [mark.args[0] for mark in item.iter_markers(name="env")] - if env_names: - env_from_option = item.config.getoption("-E") - if env_from_option not in env_names: - pytest.skip( - f"Not running in {env_names!r} environment(s). " - f"Use '-E' command line option to run this test." - ) From 9866e6e1af75e7877404e1bf6a6bdccdc2194e9a Mon Sep 17 00:00:00 2001 From: AUC Hardal Date: Tue, 16 Jun 2020 14:50:13 +0200 Subject: [PATCH 20/32] Try simple markers --- azure-pipelines.yml | 4 ++-- pytest.ini | 4 +++- qcodes/tests/conftest.py | 20 ------------------- .../test_measurement_context_manager.py | 2 +- 4 files changed, 6 insertions(+), 24 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index daff82a614a..1d4d02d013f 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -95,8 +95,8 @@ jobs: - bash: | source activate qcodes && cd qcodes && - pytest --junitxml=test-results.xml --cov=qcodes --cov-report=xml --cov-config=.coveragerc - pytest -n 0 -E serial --junitxml=test-results.xml --cov=qcodes --cov-report=xml --cov-config=.coveragerc + pytest -m ("not serial") --junitxml=test-results.xml --cov=qcodes --cov-report=xml --cov-config=.coveragerc + pytest -n 1 -m serial --junitxml=test-results.xml --cov=qcodes --cov-report=xml --cov-config=.coveragerc displayName: "Pytest on Windows" condition: and(succeededOrFailed(), eq( variables['Agent.OS'], 'Windows_NT' )) - bash: | diff --git a/pytest.ini b/pytest.ini index 12aa50764c9..392bbc80beb 100644 --- a/pytest.ini +++ b/pytest.ini @@ -3,4 +3,6 @@ junit_family=legacy addopts = -n 2 - --dist=loadfile \ No newline at end of file + --dist=loadfile + +markers = serial \ No newline at end of file diff --git a/qcodes/tests/conftest.py b/qcodes/tests/conftest.py index e71eabb78b3..a3cf4e8e5e7 100644 --- a/qcodes/tests/conftest.py +++ b/qcodes/tests/conftest.py @@ -5,17 +5,6 @@ def pytest_configure(config): config.addinivalue_line("markers", "win32: tests that only run under windows") - config.addinivalue_line( - "markers", "env(name): mark test to run only on named environment" - ) - - -def pytest_addoption(parser): - parser.addoption( - "-E", - action="store", - metavar="NAME", - help="only run tests marked with 'env(NAME)' to run in environment NAME.", ) @@ -25,15 +14,6 @@ def pytest_runtest_setup(item): if supported_platforms and sys.platform not in supported_platforms: pytest.skip(f"cannot run on platform {sys.platform}") - env_names = [mark.args[0] for mark in item.iter_markers(name="env")] - if env_names: - env_from_option = item.config.getoption("-E") - if env_from_option not in env_names: - pytest.skip( - f"Not running in {env_names!r} environment(s). " - f"Use '-E' command line option to run this test." - ) - @pytest.fixture(scope="session", autouse=True) def disable_telemetry(): diff --git a/qcodes/tests/dataset/test_measurement_context_manager.py b/qcodes/tests/dataset/test_measurement_context_manager.py index 66870998855..7350496c1a2 100644 --- a/qcodes/tests/dataset/test_measurement_context_manager.py +++ b/qcodes/tests/dataset/test_measurement_context_manager.py @@ -725,7 +725,7 @@ def collect_x_vals(results, length, state): assert collected_x_vals == given_x_vals -@pytest.mark.env("serial") +@pytest.mark.serial @pytest.mark.flaky(reruns=5) @settings(deadline=None, max_examples=25) @given(N=hst.integers(min_value=2000, max_value=3000)) From 412c47738613548bb3b8b5536cf2e23208ba99cb Mon Sep 17 00:00:00 2001 From: AUC Hardal Date: Tue, 16 Jun 2020 14:58:07 +0200 Subject: [PATCH 21/32] Fix syntax --- qcodes/tests/conftest.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qcodes/tests/conftest.py b/qcodes/tests/conftest.py index a3cf4e8e5e7..b6cd775e91b 100644 --- a/qcodes/tests/conftest.py +++ b/qcodes/tests/conftest.py @@ -5,7 +5,6 @@ def pytest_configure(config): config.addinivalue_line("markers", "win32: tests that only run under windows") - ) def pytest_runtest_setup(item): @@ -30,6 +29,7 @@ def disable_telemetry(): finally: qc.config.telemetry.enabled = original_state + @pytest.fixture(scope="session", autouse=True) def disable_config_subscriber(): """ @@ -43,4 +43,4 @@ def disable_config_subscriber(): qc.config.subscription.default_subscribers = [] yield finally: - qc.config.subscription.default_subscribers = original_state + qc.config.subscription.default_subscribers = original_state \ No newline at end of file From 797c81591bfad6a515f35aa72197cb7441c766a7 Mon Sep 17 00:00:00 2001 From: AUC Hardal Date: Tue, 16 Jun 2020 15:14:36 +0200 Subject: [PATCH 22/32] Remove brackets --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 1d4d02d013f..eb3b30f0ced 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -95,7 +95,7 @@ jobs: - bash: | source activate qcodes && cd qcodes && - pytest -m ("not serial") --junitxml=test-results.xml --cov=qcodes --cov-report=xml --cov-config=.coveragerc + pytest -m "not serial" --junitxml=test-results.xml --cov=qcodes --cov-report=xml --cov-config=.coveragerc pytest -n 1 -m serial --junitxml=test-results.xml --cov=qcodes --cov-report=xml --cov-config=.coveragerc displayName: "Pytest on Windows" condition: and(succeededOrFailed(), eq( variables['Agent.OS'], 'Windows_NT' )) From 29f392655dc839d9b316802585c4ac9189fc5c27 Mon Sep 17 00:00:00 2001 From: AUC Hardal Date: Wed, 17 Jun 2020 09:02:13 +0200 Subject: [PATCH 23/32] Separate serial in linux --- azure-pipelines.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index eb3b30f0ced..935f17c4a65 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -103,7 +103,8 @@ jobs: source activate qcodes && cd qcodes && xvfb-run --server-args="-screen 0 1024x768x24" \ - pytest --junitxml=test-results.xml --cov=qcodes --cov-report=xml --cov-config=.coveragerc + pytest -m "not serial" --junitxml=test-results.xml --cov=qcodes --cov-report=xml --cov-config=.coveragerc + pytest -n 1 -m serial --junitxml=test-results.xml --cov=qcodes --cov-report=xml --cov-config=.coveragerc displayName: "Pytest on Linux" condition: and(succeededOrFailed(), eq( variables['Agent.OS'], 'Linux' )) - task: PublishTestResults@2 From 692c0c000ce559bdc726b72fddac8f0849612cf8 Mon Sep 17 00:00:00 2001 From: AUC Hardal Date: Wed, 17 Jun 2020 09:18:28 +0200 Subject: [PATCH 24/32] Separate in travis --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 08e44761a5f..7bc32f51795 100644 --- a/.travis.yml +++ b/.travis.yml @@ -71,7 +71,8 @@ script: pip uninstall -y qcodes pip install . - cd qcodes - - py.test --cov=qcodes --cov-report xml --cov-config=.coveragerc + - py.test -m "not serial" --cov=qcodes --cov-report xml --cov-config=.coveragerc + - py.test -n 1 -m serial --cov=qcodes --cov-report xml --cov-config=.coveragerc - cd .. - mypy qcodes # check that line endings are correct avoiding mixed windows/unix style line endings From b09f8740ea7ef732bf79117fd718fa4828afd4d5 Mon Sep 17 00:00:00 2001 From: "Jens H. Nielsen" Date: Wed, 17 Jun 2020 09:53:11 +0200 Subject: [PATCH 25/32] add missing newline --- qcodes/tests/conftest.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qcodes/tests/conftest.py b/qcodes/tests/conftest.py index b6cd775e91b..7761325dccd 100644 --- a/qcodes/tests/conftest.py +++ b/qcodes/tests/conftest.py @@ -34,7 +34,7 @@ def disable_telemetry(): def disable_config_subscriber(): """ We do not want the tests to send generate subscription events unless specifically - enabled in the test. So disable any default subscriber defined + enabled in the test. So disable any default subscriber defined. """ original_state = qc.config.subscription.default_subscribers @@ -43,4 +43,4 @@ def disable_config_subscriber(): qc.config.subscription.default_subscribers = [] yield finally: - qc.config.subscription.default_subscribers = original_state \ No newline at end of file + qc.config.subscription.default_subscribers = original_state From 7c9b7ee22b68d5873e1702bedd60f3e5b06cc264 Mon Sep 17 00:00:00 2001 From: AUC Hardal Date: Wed, 17 Jun 2020 10:10:53 +0200 Subject: [PATCH 26/32] Connect tests in pipelines --- azure-pipelines.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 935f17c4a65..4e4f128bee5 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -95,7 +95,7 @@ jobs: - bash: | source activate qcodes && cd qcodes && - pytest -m "not serial" --junitxml=test-results.xml --cov=qcodes --cov-report=xml --cov-config=.coveragerc + pytest -m "not serial" --junitxml=test-results.xml --cov=qcodes --cov-report=xml --cov-config=.coveragerc && pytest -n 1 -m serial --junitxml=test-results.xml --cov=qcodes --cov-report=xml --cov-config=.coveragerc displayName: "Pytest on Windows" condition: and(succeededOrFailed(), eq( variables['Agent.OS'], 'Windows_NT' )) @@ -103,7 +103,7 @@ jobs: source activate qcodes && cd qcodes && xvfb-run --server-args="-screen 0 1024x768x24" \ - pytest -m "not serial" --junitxml=test-results.xml --cov=qcodes --cov-report=xml --cov-config=.coveragerc + pytest -m "not serial" --junitxml=test-results.xml --cov=qcodes --cov-report=xml --cov-config=.coveragerc && pytest -n 1 -m serial --junitxml=test-results.xml --cov=qcodes --cov-report=xml --cov-config=.coveragerc displayName: "Pytest on Linux" condition: and(succeededOrFailed(), eq( variables['Agent.OS'], 'Linux' )) From 491344e2b978b1bccac7120b5a5c1839b6cc7a61 Mon Sep 17 00:00:00 2001 From: AUC Hardal Date: Wed, 17 Jun 2020 10:21:36 +0200 Subject: [PATCH 27/32] Add a serial test --- qcodes/tests/dataset/test_subscribing.py | 1 + 1 file changed, 1 insertion(+) diff --git a/qcodes/tests/dataset/test_subscribing.py b/qcodes/tests/dataset/test_subscribing.py index 5912c715c60..2e005f58a5b 100644 --- a/qcodes/tests/dataset/test_subscribing.py +++ b/qcodes/tests/dataset/test_subscribing.py @@ -66,6 +66,7 @@ def subscriber(results: List[Tuple[VALUE]], length: int, return subscriber +@pytest.mark.serial def test_basic_subscription(dataset, basic_subscriber): xparam = ParamSpecBase(name='x', paramtype='numeric', From 2ff51f80d3e40400821468b66e893734b963e48e Mon Sep 17 00:00:00 2001 From: AUC Hardal Date: Wed, 17 Jun 2020 15:07:07 +0200 Subject: [PATCH 28/32] Rename code cov results for serial and parallel --- azure-pipelines.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 4e4f128bee5..721d9d73547 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -95,16 +95,16 @@ jobs: - bash: | source activate qcodes && cd qcodes && - pytest -m "not serial" --junitxml=test-results.xml --cov=qcodes --cov-report=xml --cov-config=.coveragerc && - pytest -n 1 -m serial --junitxml=test-results.xml --cov=qcodes --cov-report=xml --cov-config=.coveragerc + pytest -m "not serial" --junitxml=test-parallel-results.xml --cov=qcodes --cov-report=xml --cov-config=.coveragerc && + pytest -n 1 -m serial --junitxml=test-serial-results.xml --cov=qcodes --cov-report=xml --cov-config=.coveragerc displayName: "Pytest on Windows" condition: and(succeededOrFailed(), eq( variables['Agent.OS'], 'Windows_NT' )) - bash: | source activate qcodes && cd qcodes && xvfb-run --server-args="-screen 0 1024x768x24" \ - pytest -m "not serial" --junitxml=test-results.xml --cov=qcodes --cov-report=xml --cov-config=.coveragerc && - pytest -n 1 -m serial --junitxml=test-results.xml --cov=qcodes --cov-report=xml --cov-config=.coveragerc + pytest -m "not serial" --junitxml=test-parallel-results.xml --cov=qcodes --cov-report=xml --cov-config=.coveragerc && + pytest -n 1 -m serial --junitxml=test-serial-results.xml --cov=qcodes --cov-report=xml --cov-config=.coveragerc displayName: "Pytest on Linux" condition: and(succeededOrFailed(), eq( variables['Agent.OS'], 'Linux' )) - task: PublishTestResults@2 From 736fae09a2122ba3efc4faeb9efbd98f0167ce3c Mon Sep 17 00:00:00 2001 From: AUC Hardal Date: Wed, 17 Jun 2020 15:24:03 +0200 Subject: [PATCH 29/32] Add changelog --- docs/changes/0.16.0.rst | 7 +++++++ docs/changes/index.rst | 1 + 2 files changed, 8 insertions(+) create mode 100644 docs/changes/0.16.0.rst diff --git a/docs/changes/0.16.0.rst b/docs/changes/0.16.0.rst new file mode 100644 index 00000000000..b2522f0a1e1 --- /dev/null +++ b/docs/changes/0.16.0.rst @@ -0,0 +1,7 @@ +Changelog for QCoDeS 0.16.0 (not released yet) +============================= + +Breaking Changes: +_________________ + +* ``math`` has been renamed as ``math_utils`` (#2040). diff --git a/docs/changes/index.rst b/docs/changes/index.rst index 6c7089f51b8..48905fa7154 100644 --- a/docs/changes/index.rst +++ b/docs/changes/index.rst @@ -31,3 +31,4 @@ Changelogs 0.13.0 <0.13.0> 0.14.0 <0.14.0> 0.15.0a1 <0.15.0a1> + 0.16.0 <0.16.0> From a8e974f786dcbf3adaa40158c1db6527eeab94dd Mon Sep 17 00:00:00 2001 From: AUC Hardal Date: Wed, 17 Jun 2020 15:45:37 +0200 Subject: [PATCH 30/32] Make underline longer --- docs/changes/0.16.0.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changes/0.16.0.rst b/docs/changes/0.16.0.rst index b2522f0a1e1..5c7b3a3395d 100644 --- a/docs/changes/0.16.0.rst +++ b/docs/changes/0.16.0.rst @@ -1,5 +1,5 @@ Changelog for QCoDeS 0.16.0 (not released yet) -============================= +============================================== Breaking Changes: _________________ From dca01f8f316fa4079215faf80915ba1d0e8b1c01 Mon Sep 17 00:00:00 2001 From: AUC Hardal Date: Thu, 18 Jun 2020 11:32:43 +0200 Subject: [PATCH 31/32] Append serial cov to parallel --- azure-pipelines.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 721d9d73547..8e5c41919bb 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -96,7 +96,7 @@ jobs: source activate qcodes && cd qcodes && pytest -m "not serial" --junitxml=test-parallel-results.xml --cov=qcodes --cov-report=xml --cov-config=.coveragerc && - pytest -n 1 -m serial --junitxml=test-serial-results.xml --cov=qcodes --cov-report=xml --cov-config=.coveragerc + pytest -n 1 -m serial --junitxml=test-serial-results.xml --cov-append --cov=qcodes --cov-report=xml --cov-config=.coveragerc displayName: "Pytest on Windows" condition: and(succeededOrFailed(), eq( variables['Agent.OS'], 'Windows_NT' )) - bash: | @@ -104,7 +104,7 @@ jobs: cd qcodes && xvfb-run --server-args="-screen 0 1024x768x24" \ pytest -m "not serial" --junitxml=test-parallel-results.xml --cov=qcodes --cov-report=xml --cov-config=.coveragerc && - pytest -n 1 -m serial --junitxml=test-serial-results.xml --cov=qcodes --cov-report=xml --cov-config=.coveragerc + pytest -n 1 -m serial --junitxml=test-serial-results.xml --cov-append --cov=qcodes --cov-report=xml --cov-config=.coveragerc displayName: "Pytest on Linux" condition: and(succeededOrFailed(), eq( variables['Agent.OS'], 'Linux' )) - task: PublishTestResults@2 From d5182ae71069d65afc8bbfa196fdb785332fdd5f Mon Sep 17 00:00:00 2001 From: AUC Hardal Date: Thu, 18 Jun 2020 11:34:59 +0200 Subject: [PATCH 32/32] Appen in travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 7bc32f51795..98023f4a9ac 100644 --- a/.travis.yml +++ b/.travis.yml @@ -72,7 +72,7 @@ script: pip install . - cd qcodes - py.test -m "not serial" --cov=qcodes --cov-report xml --cov-config=.coveragerc - - py.test -n 1 -m serial --cov=qcodes --cov-report xml --cov-config=.coveragerc + - py.test -n 1 -m serial --cov-append --cov=qcodes --cov-report xml --cov-config=.coveragerc - cd .. - mypy qcodes # check that line endings are correct avoiding mixed windows/unix style line endings