diff --git a/pystencils/backends/cbackend.py b/pystencils/backends/cbackend.py index 72c9b649b18c0900f15ac65c709cfb12197359cb..f8b7e6d8a2d2216df4dc627843b1a16140dbb31d 100644 --- a/pystencils/backends/cbackend.py +++ b/pystencils/backends/cbackend.py @@ -169,7 +169,7 @@ class CBackend: method_name = "_print_" + cls.__name__ if hasattr(self, method_name): return getattr(self, method_name)(node) - raise NotImplementedError(self.__class__ + " does not support node of type " + str(type(node))) + raise NotImplementedError(self.__class__.__name__ + " does not support node of type " + node.__class__.__name__) def _print_KernelFunction(self, node): function_arguments = ["%s %s" % (str(s.symbol.dtype), s.symbol.name) for s in node.get_parameters()] diff --git a/pystencils_tests/test_print_unsupported_node.py b/pystencils_tests/test_print_unsupported_node.py new file mode 100644 index 0000000000000000000000000000000000000000..16cf6739ccb49ed1064950a4549ef1391b68f9f6 --- /dev/null +++ b/pystencils_tests/test_print_unsupported_node.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- +# +# Copyright © 2019 Stephan Seitz <stephan.seitz@fau.de> +# +# Distributed under terms of the GPLv3 license. + +""" + +""" +import pytest + +import pystencils +from pystencils.backends.cbackend import CBackend + + +class UnsupportedNode(pystencils.astnodes.Node): + + def __init__(self): + super().__init__() + + +def test_print_unsupported_node(): + with pytest.raises(NotImplementedError, match='CBackend does not support node of type UnsupportedNode'): + CBackend()(UnsupportedNode()) + + +def main(): + test_print_unsupported_node() + + +if __name__ == '__main__': + main()