Changeset 14215


Ignore:
Timestamp:
Nov 28, 2019 4:13:12 PM (7 days ago)
Author:
randersson
Message:

#5819 Fixed bug with exception that was not imported and added test

Location:
branches/dev-2385/Python/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/dev-2385/Python/src/pymodelica/compiler_wrappers.py

    r14214 r14215  
    2424from .compiler_interface import *
    2525from .compiler_logging import CompilerLogHandler, LogHandlerThread
     26from pyjmi.jmi import JMIException
    2627from pymodelica.common.core import list_to_string
    2728from .compiler_exceptions import *
     
    7879                self.set_real_option(key,value)
    7980            else:
    80                 raise JMIException("Unknown compiler option type for key: %s. \
    81                 Should be of the following types: boolean, string, integer, \
    82                 float or list" %key)
     81                err_msg="{}\n{}".format("Unknown type for compiler option: {}.".format(key),
     82                                        "Valid types are one of the following: boolean, string, integer, float or list.")
     83                raise JMIException(err_msg)
    8384
    8485    def set_compiler_logger(self, log_string):
  • branches/dev-2385/Python/src/tests_jmodelica/test_compiler.py

    r14056 r14215  
    3434import pymodelica as pym
    3535from pyfmi import load_fmu
     36from pyjmi.jmi import JMIException
    3637
    3738
     
    479480        assert 'sources/' in includedFiles, 'Source files should be present when copy_source_files_to_fmu is set to true'
    480481        assert 'sources/BouncingBall.c' in includedFiles, 'Source files should be present when copy_source_files_to_fmu is set to true'
     482
     483    @testattr(stddist_full = True)
     484    def test_invalid_format_compiler_option(self):
     485        """
     486        Test that JMIException is raised when input is a non valid type
     487        """
     488
     489        try :
     490            fmu = compile_fmu("BouncingBall", [os.path.join(get_files_path(), 'Modelica', 'BouncingBall.mo')], \
     491                              compiler_options={'c_compiler': u'gcc'},
     492                              separate_process=False)
     493
     494        except JMIException as e:
     495            err_msg = str(e)
     496            expected_msg="{}\n{}".format("Unknown type for compiler option: c_compiler.",
     497                                        "Valid types are one of the following: boolean, string, integer, float or list.")
     498            assert err_msg == expected_msg, "Incorrect error message from test!\nACTUAL:\n{}\nEXPECTED:\n{}\n".format(err_msg, expected_msg)
    481499
    482500    @testattr(stddist_full = True)
Note: See TracChangeset for help on using the changeset viewer.