コード例 #1
0
ファイル: test_config.py プロジェクト: fredtcaroli/ezCV
    def test_not_an_operator(self, operator_config):
        operator_config['implementation'] = __name__ + '.NotAnOperator'

        with pytest.raises(ConfigParsingError) as e:
            create_operator(operator_config)

        assert_terms_in_exception(e, ['not', 'operator'])
コード例 #2
0
ファイル: test_config.py プロジェクト: fredtcaroli/ezCV
    def test_invalid_implementation_no_dots(self, operator_config):
        operator_config['implementation'] = 'thisisnotanoperator'

        with pytest.raises(ConfigParsingError) as e:
            create_operator(operator_config)

        assert_terms_in_exception(e, ['invalid', 'implementation'])
コード例 #3
0
ファイル: test_config.py プロジェクト: fredtcaroli/ezCV
    def test_fail_non_param(self, operator_config):
        operator_config['params']['non_param'] = 10

        with pytest.raises(ConfigParsingError) as e:
            create_operator(operator_config)

        assert_terms_in_exception(e, ['invalid'])
コード例 #4
0
ファイル: test_config.py プロジェクト: fredtcaroli/ezCV
def test_nested_param_config():
    param_value = (3, 4)
    operator = NestedConfigParamTestOperator()
    operator.some_param = param_value
    operator_config = get_operator_config(operator)
    actual_operator = create_operator(operator_config)
    assert actual_operator.some_param == (3, 4)
コード例 #5
0
ファイル: test_config.py プロジェクト: fredtcaroli/ezCV
    def test_invalid_parameter_value(self, operator_config):
        class FailingParameter(ParameterSpec):
            def to_config(self, value: Any) -> Any:
                raise NotImplementedError()

            def from_config(self, operator_config: Any) -> None:
                assert False

        bak = OperatorForTesting.param1
        OperatorForTesting.param1 = FailingParameter(default_value=None)

        with pytest.raises(ConfigParsingError) as e:
            create_operator(operator_config)

        OperatorForTesting.param1 = bak

        assert_terms_in_exception(e, ['fail', 'pars'])
コード例 #6
0
ファイル: test_config.py プロジェクト: fredtcaroli/ezCV
    def test_missing_params(self, operator_config):
        del operator_config['params']['param2']

        operator = create_operator(operator_config)
        assert operator.param2 == param2_default_value
コード例 #7
0
ファイル: test_config.py プロジェクト: fredtcaroli/ezCV
 def test_ignore_non_parameters(self, operator_config):
     operator = create_operator(operator_config)
     assert operator.non_param is unique_object
コード例 #8
0
ファイル: test_config.py プロジェクト: fredtcaroli/ezCV
 def test_params(self, operator_config):
     operator = create_operator(operator_config)
     assert operator.param1 == param1_value
     assert operator.param2 == param2_value
コード例 #9
0
ファイル: test_config.py プロジェクト: fredtcaroli/ezCV
 def test_return_type(self, operator_config):
     operator = create_operator(operator_config)
     assert isinstance(operator, OperatorForTesting)
コード例 #10
0
ファイル: test_config.py プロジェクト: fredtcaroli/ezCV
 def test_unknown_pipeline_attribute(self, pipeline_config):
     pipeline_config['abc'] = 42
     with pytest.raises(ConfigParsingError) as e:
         _ = create_operator(pipeline_config)
     assert_terms_in_exception(e, ['unknown'])
コード例 #11
0
ファイル: test_config.py プロジェクト: fredtcaroli/ezCV
 def test_return_value(self, operator_config):
     operator = create_operator(operator_config)
     actual_operator_config = get_operator_config(operator)
     assert actual_operator_config == operator_config
コード例 #12
0
ファイル: test_config.py プロジェクト: fredtcaroli/ezCV
 def test_fail_missing_implementation(self, operator_config):
     del operator_config['implementation']
     with pytest.raises(ConfigParsingError):
         create_operator(operator_config)
コード例 #13
0
ファイル: test_config.py プロジェクト: fredtcaroli/ezCV
 def test_fail_extra_config_attributes(self, operator_config):
     operator_config['unknown_attribute'] = 42
     with pytest.raises(ConfigParsingError):
         create_operator(operator_config)