Exemplo n.º 1
0
 param(bool, 1.0, ValidationError, id="bool"),
 param(bool, Color.RED, ValidationError, id="bool"),
 param(bool, "true", BooleanNode(True), id="bool"),
 param(bool, "false", BooleanNode(False), id="bool"),
 param(bool, "on", BooleanNode(True), id="bool"),
 param(bool, "off", BooleanNode(False), id="bool"),
 # str
 param(str, "foo", StringNode("foo"), id="str"),
 param(str, True, StringNode("True"), id="str"),
 param(str, 1, StringNode("1"), id="str"),
 param(str, 1.0, StringNode("1.0"), id="str"),
 param(str, Color.RED, StringNode("Color.RED"), id="str"),
 # Color
 param(Color, "foo", ValidationError, id="Color"),
 param(Color, True, ValidationError, id="Color"),
 param(Color, 1, EnumNode(enum_type=Color, value=Color.RED),
       id="Color"),
 param(Color, 1.0, ValidationError, id="Color"),
 param(Color,
       Color.RED,
       EnumNode(enum_type=Color, value=Color.RED),
       id="Color"),
 param(Color,
       "RED",
       EnumNode(enum_type=Color, value=Color.RED),
       id="Color"),
 param(Color,
       "Color.RED",
       EnumNode(enum_type=Color, value=Color.RED),
       id="Color"),
 # bad type
Exemplo n.º 2
0
 param(bool, 1.0, ValidationError, id="bool"),
 param(bool, Color.RED, ValidationError, id="bool"),
 param(bool, "true", BooleanNode(True), id="bool"),
 param(bool, "false", BooleanNode(False), id="bool"),
 param(bool, "on", BooleanNode(True), id="bool"),
 param(bool, "off", BooleanNode(False), id="bool"),
 # str
 param(str, "foo", StringNode("foo"), id="str"),
 param(str, True, StringNode("True"), id="str"),
 param(str, 1, StringNode("1"), id="str"),
 param(str, 1.0, StringNode("1.0"), id="str"),
 param(str, Color.RED, StringNode("Color.RED"), id="str"),
 # Color
 param(Color, "foo", ValidationError, id="Color"),
 param(Color, True, ValidationError, id="Color"),
 param(Color, 1, EnumNode(enum_type=Color, value=Color.RED),
       id="Color"),
 param(Color, 1.0, ValidationError, id="Color"),
 param(Color,
       Color.RED,
       EnumNode(enum_type=Color, value=Color.RED),
       id="Color"),
 param(Color,
       "RED",
       EnumNode(enum_type=Color, value=Color.RED),
       id="Color"),
 param(Color,
       "Color.RED",
       EnumNode(enum_type=Color, value=Color.RED),
       id="Color"),
 # bad type
Exemplo n.º 3
0
 param(str, b"binary", ValidationError, id="str"),
 param(str, True, StringNode("True"), id="str"),
 param(str, 1, StringNode("1"), id="str"),
 param(str, 1.0, StringNode("1.0"), id="str"),
 param(str, Color.RED, StringNode("Color.RED"), id="str"),
 # bytes
 param(bytes, "foo", ValidationError, id="bytes"),
 param(bytes, b"binary", BytesNode(b"binary"), id="bytes"),
 param(bytes, True, ValidationError, id="bytes"),
 param(bytes, 1, ValidationError, id="bytes"),
 param(bytes, 1.0, ValidationError, id="bytes"),
 param(bytes, Color.RED, ValidationError, id="bytes"),
 # Color
 param(Color, "foo", ValidationError, id="Color"),
 param(Color, True, ValidationError, id="Color"),
 param(Color, 1, EnumNode(enum_type=Color, value=Color.RED), id="Color"),
 param(Color, 1.0, ValidationError, id="Color"),
 param(Color, Color.RED, EnumNode(enum_type=Color, value=Color.RED), id="Color"),
 param(Color, "RED", EnumNode(enum_type=Color, value=Color.RED), id="Color"),
 param(
     Color, "Color.RED", EnumNode(enum_type=Color, value=Color.RED), id="Color"
 ),
 param(Color, b"123", ValidationError, id="Color"),
 param(
     Color, "Color.RED", EnumNode(enum_type=Color, value=Color.RED), id="Color"
 ),
 # bad type
 param(IllegalType, "nope", ValidationError, id="bad_type"),
 param(IllegalType, [1, 2, 3], ValidationError, id="list_bad_type"),
 param(IllegalType, {"foo": "bar"}, ValidationError, id="dict_bad_type"),
 # DictConfig
Exemplo n.º 4
0
 pytest.param(bool, Color.RED, ValidationError, id="bool"),
 pytest.param(bool, "true", BooleanNode(True), id="bool"),
 pytest.param(bool, "false", BooleanNode(False), id="bool"),
 pytest.param(bool, "on", BooleanNode(True), id="bool"),
 pytest.param(bool, "off", BooleanNode(False), id="bool"),
 # str
 pytest.param(str, "foo", StringNode("foo"), id="str"),
 pytest.param(str, True, StringNode("True"), id="str"),
 pytest.param(str, 1, StringNode("1"), id="str"),
 pytest.param(str, 1.0, StringNode("1.0"), id="str"),
 pytest.param(str, Color.RED, StringNode("Color.RED"), id="str"),
 # Color
 pytest.param(Color, "foo", ValidationError, id="Color"),
 pytest.param(Color, True, ValidationError, id="Color"),
 pytest.param(
     Color, 1, EnumNode(enum_type=Color, value=Color.RED), id="Color"),
 pytest.param(Color, 1.0, ValidationError, id="Color"),
 pytest.param(Color,
              Color.RED,
              EnumNode(enum_type=Color, value=Color.RED),
              id="Color"),
 pytest.param(Color,
              "RED",
              EnumNode(enum_type=Color, value=Color.RED),
              id="Color"),
 pytest.param(Color,
              "Color.RED",
              EnumNode(enum_type=Color, value=Color.RED),
              id="Color"),
 # bad type
 pytest.param(IllegalType, "nope", ValidationError, id="bad_type"),
Exemplo n.º 5
0
 pytest.param(bool, 1.0, ValidationError, id="bool"),
 pytest.param(bool, Color.RED, ValidationError, id="bool"),
 pytest.param(bool, "true", BooleanNode(True), id="bool"),
 pytest.param(bool, "false", BooleanNode(False), id="bool"),
 pytest.param(bool, "on", BooleanNode(True), id="bool"),
 pytest.param(bool, "off", BooleanNode(False), id="bool"),
 # str
 pytest.param(str, "foo", StringNode("foo"), id="str"),
 pytest.param(str, True, StringNode("True"), id="str"),
 pytest.param(str, 1, StringNode("1"), id="str"),
 pytest.param(str, 1.0, StringNode("1.0"), id="str"),
 pytest.param(str, Color.RED, StringNode("Color.RED"), id="str"),
 # Color
 pytest.param(Color, "foo", ValidationError, id="Color"),
 pytest.param(Color, True, ValidationError, id="Color"),
 pytest.param(Color, 1, EnumNode(enum_type=Color, value=Color.RED), id="Color"),
 pytest.param(Color, 1.0, ValidationError, id="Color"),
 pytest.param(
     Color, Color.RED, EnumNode(enum_type=Color, value=Color.RED), id="Color"
 ),
 pytest.param(
     Color, "RED", EnumNode(enum_type=Color, value=Color.RED), id="Color"
 ),
 pytest.param(
     Color, "Color.RED", EnumNode(enum_type=Color, value=Color.RED), id="Color"
 ),
 # bad type
 pytest.param(IllegalType, "nope", ValidationError, id="bad_type"),
 # DictConfig
 pytest.param(
     dict, {"foo": "bar"}, DictConfig(content={"foo": "bar"}), id="DictConfig"