|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +# |
| 3 | +# test_ticket_692_getconnections_args.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 #692. |
| 27 | +
|
| 28 | +Test ported from SLI regression test. |
| 29 | +Ensure GetConnections validates the types of source and target arguments. |
| 30 | +
|
| 31 | +Author: Hans Ekkehard Plesser, 2013-04-18 |
| 32 | +""" |
| 33 | + |
| 34 | + |
| 35 | +INVALID_VALUES = (0, 0.0, "", {}, "foo") |
| 36 | + |
| 37 | + |
| 38 | +@pytest.mark.parametrize("key", ("source", "target")) |
| 39 | +@pytest.mark.parametrize("value", INVALID_VALUES) |
| 40 | +def test_ticket_692_getconnections_rejects_non_collections(key, value): |
| 41 | + """ |
| 42 | + Ensure GetConnections raises an error when source/target is not a node collection or sequence. |
| 43 | + """ |
| 44 | + |
| 45 | + nest.ResetKernel() |
| 46 | + |
| 47 | + with pytest.raises((TypeError, nest.kernel.NESTError)): |
| 48 | + nest.GetConnections(**{key: value}) |
0 commit comments