Esempio n. 1
0
 def test_get_phase_method_invalid_name(self, frame):
     with pytest.raises(
             AttributeError,
             match="ScalarBlock Generic Property Package called for "
             "invalid configuration option foo. Please contact the "
             "developer of the property package."):
         get_phase_method(frame, "foo", "comp")
Esempio n. 2
0
 def test_get_phase_method_not_callable(self, frame):
     frame.params.comp.config.test_arg_2 = "foo"
     with pytest.raises(
             ConfigurationError,
             match="ScalarBlock Generic Property Package received "
             "invalid value for argument test_arg_2. Value must be a "
             "method, a class with a method named expression or a "
             "module containing one of the previous."):
         get_phase_method(frame, "test_arg_2", "comp")
Esempio n. 3
0
 def test_get_phase_method_none(self, frame):
     with pytest.raises(
             GenericPropertyPackageError,
             match="Generic Property Package instance ScalarBlock "
             "called for test_arg_2, but was not provided with a "
             "method for this property. Please add a method for "
             "this property in the property parameter "
             "configuration."):
         get_phase_method(frame, "test_arg_2", "comp")
Esempio n. 4
0
    def test_get_phase_method_simple(self, frame):
        def test_arg():
            return "bar"

        frame.params.comp.config.test_arg_2 = test_arg

        mthd = get_phase_method(frame, "test_arg_2", "comp")
        assert mthd() == "bar"
Esempio n. 5
0
    def test_get_phase_method_class_w_return_expression(self, frame):
        class TestClass():
            def return_expression():
                return "bar"

        frame.params.comp.config.test_arg_2 = TestClass

        mthd = get_phase_method(frame, "test_arg_2", "comp")
        assert mthd() == "bar"