Changeset 13603


Ignore:
Timestamp:
Sep 26, 2019 11:54:03 AM (3 months ago)
Author:
randersson
Message:

#5819 Updated test to correctly test what it is supposed to. Mostly adding more calls to setUp() in order to properly reset the FMU. Also modified some tests to be working independently because they were only working because of the order all the tests.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/dev-5819/Python/src/tests_jmodelica/initialization/test_KINsolver_options.py

    r13500 r13603  
    22# -*- coding: utf-8 -*-
    33
    4 # Copyright (C) 2013 Modelon AB
     4# Copyright (C) 2019 Modelon AB
    55#
    66# This program is free software: you can redistribute it and/or modify
     
    5353        test if model options are correctly initialized
    5454        """
     55        self.setUp()
    5556        nose.tools.assert_true(self.model.get('_enforce_bounds'))
    5657        nose.tools.assert_equals(self.model.get('_iteration_variable_scaling'), 1)
     
    6566        test if user can set variable scaling.
    6667        """
     68        self.setUp()
    6769        self.model.set('_iteration_variable_scaling', 0)
    6870        self.model.initialize()
     
    7880        test if user can set variable scaling.
    7981        """
     82        self.setUp()
    8083        self.model.set('_residual_equation_scaling',1)
    8184        self.model.initialize()
     
    109112        test if maxiterations works. error propagation is tested.
    110113        """
     114        self.setUp()
    111115        #Test with too few iterations
    112116        self.model.set('_nle_solver_max_iter', 3)
     
    119123   
    120124    @testattr(stddist_full = True)   
    121     def test_debbug_file(self):
     125    def test_debug_file(self):
    122126        """
    123127        That the correct amount of debug info is created.
    124128        """
     129        self.setUp()
    125130        self.model.set_debug_logging(True)
    126131        self.model.set('_log_level',1)
     
    176181        That the correct solution is stored in the debug file.
    177182        """
    178        
     183        self.setUp()
    179184        self.model.initialize()
    180185        extract_jmi_log('test_KINsolver_log.xml', self.log_file_name)
     
    213218        test if model options are correctly initialized
    214219        """
     220        self.setUp()
    215221        nose.tools.assert_true(self.model.get('_enforce_bounds'))
    216222        nose.tools.assert_equals(self.model.get('_iteration_variable_scaling'), 1)
     
    240246        test if user can set variable scaling.
    241247        """
     248        self.setUp()
    242249        self.model.set('_residual_equation_scaling',1)
    243250        self.model.initialize()
    244251        log = parse_jmi_log(self.log_file_name)
    245252        solves = gather_solves(log)
    246         result = solves[0].block_solves[0].iterations[0].residual_scaling
     253        result = solves[1].block_solves[0].iterations[0].residual_scaling
    247254        expected = N.array([1., 1.])
    248255        err_msg = "Arrays are supposed to be different but are actually equal. Result={}\nExpected={}".format(result, expected)
     
    286293        That the correct amount of debug info is created.
    287294        """
     295        self.setUp('test_KINsolver_options_log_ll1.txt')
    288296        self.model.set_debug_logging(True)
    289297        self.model.set('_log_level',1)
     
    333341        That the correct solution is stored in the debug file.
    334342        """
    335        
     343        self.setUp()
    336344        self.model.initialize()
    337345        extract_jmi_log('test_KINsolver_log.xml', self.log_file_name)
Note: See TracChangeset for help on using the changeset viewer.