| 1 |
import pytest |
| 2 |
|
| 3 |
from brian2 import * |
| 4 |
|
| 5 |
|
| 6 |
def test_error_message(): |
| 7 |
if prefs.codegen.target != "numpy": |
| 8 |
pytest.skip("numpy-only test") |
| 9 |
|
| 10 |
@check_units(x=1, result=1) |
| 11 |
def foo(x): |
| 12 |
raise ValueError() |
| 13 |
|
| 14 |
G = NeuronGroup(1, "v : 1") |
| 15 |
G.run_regularly("v = foo(3)") |
| 16 |
with pytest.raises(BrianObjectException) as exc: |
| 17 |
run(defaultclock.dt) |
| 18 |
# The actual code line should be mentioned in the error message |
| 19 |
exc.match("v = foo(3)") |
| 20 |
|
| 21 |
|
| 22 |
if __name__ == "__main__": |
| 23 |
prefs.codegen.target = "numpy" |
| 24 |
test_error_message() |