generated from jCloud/repository-template
Remove core.python.arguments.PythonFunctionArgumentDefault; use strings instead
This commit is contained in:
@@ -1,55 +0,0 @@
|
||||
# Copyright 2026 jCloud Services GbR
|
||||
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from src.jcloud_docsgen.core.python.arguments import PythonFunctionArgumentDefault
|
||||
import pytest
|
||||
import ast
|
||||
|
||||
@pytest.mark.parametrize('default,expected', [
|
||||
(PythonFunctionArgumentDefault(ast.Constant(value = '')), ast.Constant),
|
||||
(PythonFunctionArgumentDefault(ast.Constant(value = 'x')), ast.Constant),
|
||||
(PythonFunctionArgumentDefault(ast.Constant(value = None)), ast.Constant),
|
||||
(PythonFunctionArgumentDefault(ast.Constant(value = 1)), ast.Constant),
|
||||
])
|
||||
def test_PythonFunctionArgumentDefault_value_attribute_type(default, expected):
|
||||
assert isinstance(default.value, expected)
|
||||
|
||||
@pytest.mark.parametrize('value,expected_exception_msg', [
|
||||
(None, 'expected \'expr\', got \'NoneType\''),
|
||||
(1, 'expected \'expr\', got \'int\''),
|
||||
('x', 'expected \'expr\', got \'str\''),
|
||||
(42, 'expected \'expr\', got \'int\''),
|
||||
(4.2, 'expected \'expr\', got \'float\''),
|
||||
])
|
||||
def test_PythonFunctionArgumentDefault_raises_TypeError(value, expected_exception_msg):
|
||||
with pytest.raises(TypeError) as exc_info:
|
||||
PythonFunctionArgumentDefault(value)
|
||||
assert str(exc_info.value) == expected_exception_msg
|
||||
|
||||
@pytest.mark.parametrize('default1,default2,expected', [
|
||||
(PythonFunctionArgumentDefault(ast.Constant(value = 1)), PythonFunctionArgumentDefault(ast.Constant(value = 1)), True),
|
||||
(PythonFunctionArgumentDefault(ast.Constant(value = 1)), PythonFunctionArgumentDefault(ast.Constant(value = 2)), False),
|
||||
(PythonFunctionArgumentDefault(ast.Constant(value = 'a')), PythonFunctionArgumentDefault(ast.Constant(value = 2)), False),
|
||||
(PythonFunctionArgumentDefault(ast.Constant(value = 'a')), PythonFunctionArgumentDefault(ast.Constant(value = 'a')), True),
|
||||
(PythonFunctionArgumentDefault(ast.Constant(value = 'a')), PythonFunctionArgumentDefault(ast.Constant(value = 'b')), False),
|
||||
(PythonFunctionArgumentDefault(ast.List(elts = [])), PythonFunctionArgumentDefault(ast.List(elts = [])), True),
|
||||
(PythonFunctionArgumentDefault(ast.List(elts = [1])), PythonFunctionArgumentDefault(ast.List(elts = [])), False),
|
||||
(PythonFunctionArgumentDefault(ast.List(elts = [1])), PythonFunctionArgumentDefault(ast.List(elts = [1])), True),
|
||||
(PythonFunctionArgumentDefault(ast.List(elts = [1])), PythonFunctionArgumentDefault(ast.List(elts = [2])), False),
|
||||
(PythonFunctionArgumentDefault(ast.List(elts = [1])), PythonFunctionArgumentDefault(ast.List(elts = [1, 2])), False),
|
||||
(PythonFunctionArgumentDefault(ast.List(elts = [1, 2])), PythonFunctionArgumentDefault(ast.List(elts = [1, 2])), True),
|
||||
(PythonFunctionArgumentDefault(ast.List(elts = [2, 1])), PythonFunctionArgumentDefault(ast.List(elts = [1, 2])), False),
|
||||
])
|
||||
def test_PythonFunctionArgumentDefault___eq__(default1, default2, expected):
|
||||
assert (default1 == default2) == expected
|
||||
Reference in New Issue
Block a user