Skip to content

Commit ef70258

Browse files
committed
Modify to cover bad property tests for setters
1 parent dbc6a29 commit ef70258

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

testsuite/pytests/sli2py_regressions/test_issue_545.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,27 @@
2020
# along with NEST. If not, see <http://www.gnu.org/licenses/>.
2121

2222
"""
23-
This test ensures that calling SetDefaults with a wrong datatype sets it correctly nonetheless.
23+
This test ensures that calling various setters with incorrect properties correctly raises an error.
2424
"""
2525

2626
import nest
2727
import pytest
2828

2929

3030
@pytest.mark.skipif_missing_threads
31-
@pytest.mark.parametrize('num_threads', [1, 4])
32-
@pytest.mark.parametrize('data', [('stdp_synapse', 'tau_plus'), ('iaf_psc_alpha', 'C_m')])
33-
def test_incorrect_integer_data_type_works_with_defaults(num_threads, data):
31+
def test_setters_raise_error_on_bad_properties():
3432
nest.ResetKernel()
35-
nest.local_num_threads = num_threads
36-
model, option = data
33+
nest.local_num_threads = 4
3734

38-
nest.SetDefaults(model,
39-
{option: 10})
40-
assert nest.GetDefaults(model)[option] == 10
35+
# test defaults
36+
with pytest.raises(nest.kernel.NESTErrors.BadProperty):
37+
nest.SetDefaults('iaf_psc_alpha', {'tau_m': -10})
38+
39+
# test neuron
40+
n = nest.Create('iaf_psc_alpha')
41+
with pytest.raises(nest.kernel.NESTErrors.BadProperty):
42+
n.set({'tau_m': -10})
43+
44+
# test synapse
45+
with pytest.raises(nest.kernel.NESTErrors.BadDelay):
46+
nest.Connect(n, n, syn_spec={'delay': -10})

0 commit comments

Comments
 (0)