Skip to content

Commit b5505bb

Browse files
authored
Merge pull request #3526 from jessica-mitchell/ticket737
Port regression test ticket 737 to Pytests
2 parents 0d03181 + 1f23170 commit b5505bb

File tree

3 files changed

+84
-102
lines changed

3 files changed

+84
-102
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# test_ticket_737.py
4+
#
5+
# This file is part of NEST.
6+
#
7+
# Copyright (C) 2004 The NEST Initiative
8+
#
9+
# NEST is free software: you can redistribute it and/or modify
10+
# it under the terms of the GNU General Public License as published by
11+
# the Free Software Foundation, either version 2 of the License, or
12+
# (at your option) any later version.
13+
#
14+
# NEST is distributed in the hope that it will be useful,
15+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
# GNU General Public License for more details.
18+
#
19+
# You should have received a copy of the GNU General Public License
20+
# along with NEST. If not, see <http://www.gnu.org/licenses/>.
21+
22+
import nest
23+
import pytest
24+
25+
"""
26+
Regression test for Ticket #737.
27+
28+
Test ported from SLI regression test
29+
Ensure that stimulation devices can only be connected with a single synapse type.
30+
"""
31+
32+
33+
# Get all viable stimulator models
34+
SKIP_LIST = ["step_rate_generator"]
35+
stimulators = [
36+
m for m in nest.node_models if m not in SKIP_LIST and nest.GetDefaults(m).get("element_type") == "stimulator"
37+
]
38+
39+
40+
@pytest.fixture(params=stimulators)
41+
def stimulator_and_neuron(request):
42+
stim_model = request.param
43+
44+
nest.ResetKernel()
45+
stim = nest.Create(stim_model)
46+
n = nest.Create("iaf_psc_alpha")
47+
48+
yield stim, n
49+
50+
51+
def test_ticket_737_all_static(stimulator_and_neuron):
52+
"""Confirm we can connect multiple times with static_synapse."""
53+
54+
stim, n = stimulator_and_neuron
55+
56+
nest.Connect(stim, n, "all_to_all", syn_spec="static_synapse")
57+
nest.Connect(stim, n, "all_to_all", syn_spec="static_synapse")
58+
59+
60+
def test_ticket_737_user_defined(stimulator_and_neuron):
61+
"""Confirm we can connect multiple times with user-defined synapse model."""
62+
63+
stim, n = stimulator_and_neuron
64+
65+
synmodel = f"{stim.model}_syn"
66+
nest.CopyModel("static_synapse", synmodel)
67+
nest.Connect(stim, n, "all_to_all", syn_spec=synmodel)
68+
nest.Connect(stim, n, "all_to_all", syn_spec=synmodel)
69+
70+
71+
def test_ticket_737_break_on_different_types(stimulator_and_neuron):
72+
"""Confirm NEST raises error if trying to connect one generator with different synpase models."""
73+
74+
stim, n = stimulator_and_neuron
75+
76+
synmodel = f"{stim.model}_syn"
77+
nest.CopyModel("static_synapse", synmodel)
78+
nest.Connect(stim, n, "all_to_all", syn_spec="static_synapse")
79+
80+
with pytest.raises(nest.kernel.NESTError, match="IllegalConnection"):
81+
nest.Connect(stim, n, "all_to_all", syn_spec=synmodel)

testsuite/regressiontests/ticket-737.sli

Lines changed: 0 additions & 99 deletions
This file was deleted.

testsuite/summarize_tests.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@
4444
expected_num_tests = {
4545
"01 basetests": 6,
4646
"02 selftests": 8,
47-
"03 unittests": 27,
48-
"04 regressiontests": 45, # does not include the two python-dependent tests
49-
"05 mpitests": 77,
47+
"03 unittests": 1, # set to 1 to avoid complications during porting to Pytest
48+
"04 regressiontests": 1, # set to 1 to avoid complications during porting to Pytest
49+
"05 mpitests": 1, # set to 1 to avoid complications during porting to Pytest
5050
"06 musictests": 1,
5151
"07 pynesttests": 3719, # without thread-dependent cases
5252
"07 pynesttests mpi 2": (230, 172), # first case without thread-dependent cases

0 commit comments

Comments
 (0)