diff --git a/testsuite/pytests/sli2py_regressions/test_ticket_464.py b/testsuite/pytests/sli2py_regressions/test_ticket_464.py new file mode 100644 index 0000000000..206dd6a48b --- /dev/null +++ b/testsuite/pytests/sli2py_regressions/test_ticket_464.py @@ -0,0 +1,70 @@ +# -*- coding: utf-8 -*- +# +# test_ticket_464.py +# +# This file is part of NEST. +# +# Copyright (C) 2004 The NEST Initiative +# +# NEST is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# NEST is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with NEST. If not, see . +import nest +import pytest + + +# Placeholder decorator to simulate MPI check +def skip_if_have_mpi(func): + try: + # Simulates checking for MPI (not directly feasible in Python) + import MPI + + return pytest.mark.skip(reason="Test skipped if NEST has MPI support")(func) + except ImportError: + return func + + +@skip_if_have_mpi +def test_ticket_464(): + """ + Ensure that NEST triggers an error with a frozen multimeter connected to a node. + + This test has been modified to reflect that NEST now protects multimeter against being frozen. + The first test triggers an error instead of an assertion, and crash_or_die has been replaced by fail_or_die. + + Remarks: + This test has been modified (2011-02-11) to reflect the fact that NEST now protects + multimeter against being frozen. Thus, the first test triggers an error instead of + and assertion, and crash_or_die has been replaced by fail_or_die. + + Author: Hans Ekkehard Plesser, 2010-10-04 + """ + + # Test: multimeter frozen, should trigger error + nest.ResetKernel() + # Attempt to create and freeze a multimeter + mm = nest.Create("multimeter", params={"record_from": ["V_m"]}) + with pytest.raises(Exception): # Expect an error due to frozen multimeter + mm.set(frozen=True) # Set frozen status + iaf_neuron = nest.Create("iaf_psc_alpha") + nest.Connect(mm, iaf_neuron) + nest.Simulate(3.0) + + # Test: multimeter thawed, should run fine + nest.ResetKernel() + mm = nest.Create("multimeter", params={"record_from": ["V_m"]}) + mm.set(frozen=False) # Ensure multimeter is not frozen + iaf_neuron = nest.Create("iaf_psc_alpha") + nest.Connect(mm, iaf_neuron) + nest.Simulate(3.0) # Should run without issues + + # If we reach here, the second test has passed diff --git a/testsuite/regressiontests/ticket-464.sli b/testsuite/regressiontests/ticket-464.sli deleted file mode 100644 index 53be57531b..0000000000 --- a/testsuite/regressiontests/ticket-464.sli +++ /dev/null @@ -1,73 +0,0 @@ -/* - * ticket-464.sli - * - * This file is part of NEST. - * - * Copyright (C) 2004 The NEST Initiative - * - * NEST is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * NEST is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with NEST. If not, see . - * - */ - -/** @BeginDocumentation - -Name: testsuite::ticket-464 - Ensure that UniversalDataLogger triggers assertion with frozen multimeter. - -Synopsis: (ticket-464) run -> NEST exits if test fails - -Description: -Ensure that NEST triggers an assertion in UniversalDataLogger::record_data() instead of seg faulting -when a frozen multimeter is connected to a node. - -Remarks: -This test has been modified (2011-02-11) to reflect the fact that NEST now protects -multimeter against being frozen. Thus, the first test triggers an error instead of -and assertion, and crash_or_die has been replaced by fail_or_die. - -This test will only be executed if NEST has been compiled without MPI support. - -Author: Hans Ekkehard Plesser, 2010-10-04 - */ - -(unittest) run -/unittest using - -% preparatory work for proper test code in case NEST is complied with MPI support -% For now we just ignore this test, this will later be replaced -% by a restart of NEST with a serial binary. -skip_if_have_mpi - -M_ERROR setverbosity - -% crash_or_die needs explicit code, cannot handle function names. - -% multimeter frozen, should trigger assertion -{ - ResetKernel - /multimeter << /record_from [/V_m] >> Create dup << /frozen true >> SetStatus - /iaf_psc_alpha Create - Connect - 3.0 Simulate -} fail_or_die % was crash_or_die - -% multimeter thawed, should run fine -{ - ResetKernel - /multimeter << /record_from [/V_m] >> Create dup << /frozen false >> SetStatus - /iaf_psc_alpha Create - Connect - 3.0 Simulate -} pass_or_die - -endusing \ No newline at end of file