Skip to content

Commit

Permalink
Use mark.usefixtures in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
GateBuilder committed Mar 6, 2020
1 parent 7605bfb commit 9e3ab8c
Showing 1 changed file with 34 additions and 20 deletions.
54 changes: 34 additions & 20 deletions qcodes/tests/test_doNd.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,62 +65,71 @@ def test_param_callable(_param_callable):
assert _param_modified.get() == 2


@pytest.mark.usefixtures("plot_close")
@pytest.mark.parametrize('period, plot', [(None, True), (None, False),
(1, True), (1, False)])
def test_do0d_with_real_parameter(_param, period, plot, plot_close):
def test_do0d_with_real_parameter(_param, period, plot):
do0d(_param, write_period=period, do_plot=plot)


@pytest.mark.usefixtures("plot_close")
@pytest.mark.parametrize('period, plot', [(None, True), (None, False),
(1, True), (1, False)])
def test_do0d_with_complex_parameter(_param_complex, period, plot, plot_close):
def test_do0d_with_complex_parameter(_param_complex, period, plot):
do0d(_param_complex, write_period=period, do_plot=plot)


@pytest.mark.usefixtures("plot_close")
@pytest.mark.parametrize('period, plot', [(None, True), (None, False),
(1, True), (1, False)])
def test_do0d_with_a_callable(_param_callable, period, plot, plot_close):
def test_do0d_with_a_callable(_param_callable, period, plot):
do0d(_param_callable, write_period=period, do_plot=plot)


@pytest.mark.usefixtures("plot_close")
@pytest.mark.parametrize('period, plot', [(None, True), (None, False),
(1, True), (1, False)])
def test_do0d_with_multiparameters(_param, _param_complex, period, plot,
plot_close):
def test_do0d_with_multiparameters(_param, _param_complex, period, plot):
do0d(_param, _param_complex, write_period=period, do_plot=plot)


@pytest.mark.usefixtures("plot_close")
@pytest.mark.parametrize('period, plot', [(None, True), (None, False),
(1, True), (1, False)])
def test_do0d_with_parameter_and_a_callable(_param_complex, _param_callable,
period, plot, plot_close):
period, plot):
do0d(_param_callable, _param_complex, write_period=period, do_plot=plot)


def test_do0d_output_type_real_parameter(_param, plot_close):
@pytest.mark.usefixtures("plot_close")
def test_do0d_output_type_real_parameter(_param):
data = do0d(_param)
assert isinstance(data[0], DataSet) is True


def test_do0d_output_type_complex_parameter(_param_complex, plot_close):
@pytest.mark.usefixtures("plot_close")
def test_do0d_output_type_complex_parameter(_param_complex):
data_complex = do0d(_param_complex)
assert isinstance(data_complex[0], DataSet) is True


def test_do0d_output_type_callable(_param_callable, plot_close):
@pytest.mark.usefixtures("plot_close")
def test_do0d_output_type_callable(_param_callable):
data_func = do0d(_param_callable)
assert isinstance(data_func[0], DataSet) is True


def test_do0d_output_data(_param, plot_close):
@pytest.mark.usefixtures("plot_close")
def test_do0d_output_data(_param):
exp = do0d(_param)
data = exp[0]
assert data.parameters == _param.name
assert data.get_values(_param.name)[0][0] == _param.get()


@pytest.mark.usefixtures("plot_close")
@pytest.mark.parametrize('delay', [0, 0.1, 1])
def test_do1d_with_real_parameter(_param_set, _param, delay, plot_close):
def test_do1d_with_real_parameter(_param_set, _param, delay):

start = 0
stop = 1
Expand All @@ -129,9 +138,9 @@ def test_do1d_with_real_parameter(_param_set, _param, delay, plot_close):
do1d(_param_set, start, stop, num_points, delay, _param)


@pytest.mark.usefixtures("plot_close")
@pytest.mark.parametrize('delay', [0, 0.1, 1])
def test_do1d_with_complex_parameter(_param_set, _param_complex, delay,
plot_close):
def test_do1d_with_complex_parameter(_param_set, _param_complex, delay):

start = 0
stop = 1
Expand All @@ -140,9 +149,9 @@ def test_do1d_with_complex_parameter(_param_set, _param_complex, delay,
do1d(_param_set, start, stop, num_points, delay, _param_complex)


@pytest.mark.usefixtures("plot_close")
@pytest.mark.parametrize('delay', [0, 0.1, 1])
def test_do1d_with_multiparameter(_param_set, _param, _param_complex, delay,
plot_close):
def test_do1d_with_multiparameter(_param_set, _param, _param_complex, delay):

start = 0
stop = 1
Expand All @@ -151,8 +160,9 @@ def test_do1d_with_multiparameter(_param_set, _param, _param_complex, delay,
do1d(_param_set, start, stop, num_points, delay, _param, _param_complex)


@pytest.mark.usefixtures("plot_close")
@pytest.mark.parametrize('delay', [0, 0.1, 1])
def test_do1d_output_type_real_parameter(_param_set, _param, delay, plot_close):
def test_do1d_output_type_real_parameter(_param_set, _param, delay):

start = 0
stop = 1
Expand All @@ -162,7 +172,8 @@ def test_do1d_output_type_real_parameter(_param_set, _param, delay, plot_close):
assert isinstance(data[0], DataSet) is True


def test_do1d_output_data(_param, _param_set, plot_close):
@pytest.mark.usefixtures("plot_close")
def test_do1d_output_data(_param, _param_set):

start = 0
stop = 1
Expand All @@ -177,9 +188,10 @@ def test_do1d_output_data(_param, _param_set, plot_close):
assert data.get_values(_param_set.name) == [[0], [0.25], [0.5], [0.75], [1]]


@pytest.mark.usefixtures("plot_close")
@pytest.mark.parametrize('sweep, columns', [(False, False), (False, True),
(True, False), (True, True)])
def test_do2d(_param, _param_complex, _param_set, sweep, columns, plot_close):
def test_do2d(_param, _param_complex, _param_set, sweep, columns):

start_p1 = 0
stop_p1 = 1
Expand All @@ -196,7 +208,8 @@ def test_do2d(_param, _param_complex, _param_set, sweep, columns, plot_close):
_param, _param_complex, set_before_sweep=sweep, flush_columns=columns)


def test_do2d_output_type(_param, _param_complex, _param_set, plot_close):
@pytest.mark.usefixtures("plot_close")
def test_do2d_output_type(_param, _param_complex, _param_set):

start_p1 = 0
stop_p1 = 0.5
Expand All @@ -214,7 +227,8 @@ def test_do2d_output_type(_param, _param_complex, _param_set, plot_close):
assert isinstance(data[0], DataSet) is True


def test_do2d_output_data(_param, _param_complex, _param_set, plot_close):
@pytest.mark.usefixtures("plot_close")
def test_do2d_output_data(_param, _param_complex, _param_set):

start_p1 = 0
stop_p1 = 0.5
Expand Down

0 comments on commit 9e3ab8c

Please sign in to comment.