def test_get_ref_type_error() -> None: with raises(ValueError): _utils.get_ref_type(AnyNode(), "foo")
BooleanNode, BytesNode, EnumNode, FloatNode, IntegerNode, StringNode, ) from omegaconf.omegaconf import _node_wrap from tests import Color, ConcretePlugin, Dataframe, IllegalType, Plugin, User @mark.parametrize( "target_type, value, expected", [ # Any param(Any, "foo", AnyNode("foo"), id="any"), param(Any, b"binary", AnyNode(b"binary"), id="any"), param(Any, True, AnyNode(True), id="any"), param(Any, 1, AnyNode(1), id="any"), param(Any, 1.0, AnyNode(1.0), id="any"), param(Any, b"123", AnyNode(b"123"), id="any"), param(Any, Color.RED, AnyNode(Color.RED), id="any"), param(Any, {}, DictConfig(content={}), id="any_as_dict"), param(Any, [], ListConfig(content=[]), id="any_as_list"), # int param(int, "foo", ValidationError, id="int"), param(int, b"binary", ValidationError, id="int"), param(int, True, ValidationError, id="int"), param(int, 1, IntegerNode(1), id="int"), param(int, 1.0, ValidationError, id="int"), param(int, Color.RED, ValidationError, id="int"),
from tests import ( Color, ConcretePlugin, Dataframe, IllegalType, Plugin, User, does_not_raise, ) @mark.parametrize( "target_type, value, expected", [ # Any param(Any, "foo", AnyNode("foo"), id="any"), param(Any, True, AnyNode(True), id="any"), param(Any, 1, AnyNode(1), id="any"), param(Any, 1.0, AnyNode(1.0), id="any"), param(Any, Color.RED, AnyNode(Color.RED), id="any"), param(Any, {}, DictConfig(content={}), id="any_as_dict"), param(Any, [], ListConfig(content=[]), id="any_as_list"), # int param(int, "foo", ValidationError, id="int"), param(int, True, ValidationError, id="int"), param(int, 1, IntegerNode(1), id="int"), param(int, 1.0, ValidationError, id="int"), param(int, Color.RED, ValidationError, id="int"), # float param(float, "foo", ValidationError, id="float"), param(float, True, ValidationError, id="float"),
ref_type=ref_type, value=None, is_optional=is_optional, parent=None, key=None, ) assert type(ret) == expected_type # noinspection PyComparisonWithNone assert ret == None # noqa E711 @mark.parametrize( "target_type, value, expected", [ # Any param(Any, "foo", AnyNode("foo"), id="any"), param(Any, b"binary", AnyNode(b"binary"), id="any"), param(Any, Path("hello.txt"), AnyNode(Path("hello.txt")), id="any"), param(Any, True, AnyNode(True), id="any"), param(Any, 1, AnyNode(1), id="any"), param(Any, 1.0, AnyNode(1.0), id="any"), param(Any, b"123", AnyNode(b"123"), id="any"), param(Any, Color.RED, AnyNode(Color.RED), id="any"), param(Any, {}, DictConfig(content={}), id="any_as_dict"), param(Any, [], ListConfig(content=[]), id="any_as_list"), # int param(int, "foo", ValidationError, id="int"), param(int, b"binary", ValidationError, id="int"), param(int, Path("hello.txt"), ValidationError, id="int"), param(int, True, ValidationError, id="int"), param(int, 1, IntegerNode(1), id="int"),