|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +# |
| 3 | +# test_issue_659.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 | +Regression test for Issue #659 (GitHub). |
| 23 | +
|
| 24 | +This test checks that calling Run or Cleanup without calling Prepare first results in an error. |
| 25 | +""" |
| 26 | + |
| 27 | +import nest |
| 28 | +import pytest |
| 29 | + |
| 30 | + |
| 31 | +def test_run_without_prepare(): |
| 32 | + """ |
| 33 | + Test that calling Run without Prepare results in an error. |
| 34 | + """ |
| 35 | + nest.ResetKernel() |
| 36 | + with pytest.raises(nest.kernel.NESTError): |
| 37 | + nest.Run(10.0) |
| 38 | + |
| 39 | + |
| 40 | +def test_cleanup_without_prepare(): |
| 41 | + """ |
| 42 | + Test that calling Cleanup without Prepare results in an error. |
| 43 | + """ |
| 44 | + nest.ResetKernel() |
| 45 | + with pytest.raises(Exception): |
| 46 | + nest.Cleanup() |
| 47 | + |
| 48 | + |
| 49 | +def test_prepare_twice(): |
| 50 | + """ |
| 51 | + Test that calling Prepare twice results in an error. |
| 52 | + """ |
| 53 | + nest.ResetKernel() |
| 54 | + nest.Prepare() |
| 55 | + with pytest.raises(Exception): |
| 56 | + nest.Prepare() |
| 57 | + |
| 58 | + |
| 59 | +def test_run_after_cleanup_without_prepare(): |
| 60 | + """ |
| 61 | + Test that calling Run after Cleanup, without Prepare, results in an error. |
| 62 | + """ |
| 63 | + nest.ResetKernel() |
| 64 | + nest.Prepare() |
| 65 | + nest.Run(10.0) |
| 66 | + nest.Cleanup() |
| 67 | + with pytest.raises(Exception): |
| 68 | + nest.Run(10.0) |
0 commit comments