class Schema_04(Schema): int_attr = Int("int_attr", default=123) str_attr = Str("str_attr", default="test") str_attr_null = Str(default=None) list_attr = List("list_attr", NestedSchema_01()) list_attr_w_default = List("list_attr_w_default", item=Int(), default=[1, 2, 3]) nested = NestedSchema_02("nested")
class Schema_03(Schema): int_attr = Int("int_attr", default=123, help="an integer attribute") str_attr = Str("str_attr", default="test", help="a unicode attribute") bool_attr = Bool("bool_attr", help="a boolean attribute") bool_attr_w_dflt = Bool("bool_attr_w_dflt", default=False, help="a boolean attribute") bool_attr_w_dflt_yes = Bool("bool_attr_w_dflt_yes", default=True, help="a boolean attribute") float_attr = Float("float_attr", default=1.23, help="a float attribute") list_attr_int = List("list_attr_int", Int("list_attr_int_item")) list_attr_str = List("list_attr_str", Str("list_attr_str_item")) list_attr_schema = List(name="list_attr_schema", item=NestedSchema_01()) nested = NestedSchema_02("nested") int_attr_disabled = Int("int_attr_disabled", cli=False) int_attr_fntgl_on = Int(cli=lambda x: True, default=1) int_attr_fntgl_off = Int(cli=lambda x: False, default=1)
def test_list(): with pytest.raises(TypeError): attribute = List("test", 123) item = Int("item") attribute = List("test", item) assert attribute.item == item assert attribute.name == "test" class Item(Schema): test_sub = Int("test_sub") item = Item() attribute = List("test", item) assert attribute.item == item attribute = List("test", Int()) attribute = List(item=Int()) attribute = List(name="test", item=Int())
"require_exist": False }), (Directory, relative_dir, absolute_dir, invalid_dir, {}), (Directory, home_dir, home_dir_expanded, invalid_dir, {}), (File, valid_file, valid_file, invalid_file, {}), (File, invalid_file, invalid_file, None, { "require_exist": False }), (File, home_file, home_file_expanded, None, { "require_exist": False }), (File, relative_file, absolute_file, None, { "require_exist": False }), (List, [1, 2, 3], [1, 2, 3], "test", { "item": Int("test") }), (List, [1, 2, 3], [1, 2, 3], ["test"], { "item": Int("test") }), (Dict, { "a": 123 }, { "a": 123 }, { "a": "b" }, { "item": Int() }), (Dict, { "a": "123"
class Item(Schema): test_sub = Int("test_sub")
class ServerSchema(Schema): host = IpAddress() port = Int(default=80)
class Nested_Schema(Schema): int_attr = Int(default=10) int_attr_choices = Int(choices=[1, 2, 3], default=1, help="This can be 1,2 or 3")
class Example_Schema(Schema): int_attr = Int(default=123) str_attr = Str(default="test") str_attr_null = Str(default=None) list_attr_w_default = List(item=Int(), default=[1, 2, 3]) nested = Nested_Schema()
class Schema_07(Schema): str_attr = Str(default="test123") str_attr_null = Str(default=None) int_attr = Int(default=123) str_attr_nd = Str()
class NestedSchema_02(Schema): int_attr = Int("int_attr") int_attr_choices = Int("int_attr_choices", choices=[1, 2, 3], default=1, help="This can be 1,2 or 3")
class NestedSchema_01(Schema): int_attr = Int("int_attr")
class Schema_02(Schema): int_attr = Int("int_attr", default=123) str_attr = Str("str_attr", default="test") list_attr = List(item=NestedSchema_01()) str_attr_null = Str(default=None) nested = NestedSchema_01("nested")
class Schema_01(Schema): int_attr = Int("int_attr") str_attr = Str("str_attr") list_attr = List("list_attr", NestedSchema_01()) nested = NestedSchema_01("nested")
class Schema_13(Schema): int_attr = Int() str_attr = Str()