diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 10db3ff..8096448 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -34,7 +34,7 @@ jobs: - name: Install enchant run: | sudo apt-get -qq update - sudo apt-get -y install enchant + sudo apt-get -y install enchant-2 - name: Install dependencies run: | diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index dc8d7f9..80d024a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,22 +1,22 @@ repos: - repo: https://github.com/psf/black - rev: 22.8.0 + rev: 23.11.0 hooks: - id: black args: ["--target-version", "py37"] - repo: https://github.com/PyCQA/isort - rev: 5.10.1 + rev: 5.12.0 hooks: - id: isort - repo: https://github.com/pre-commit/pygrep-hooks - rev: v1.9.0 + rev: v1.10.0 hooks: - id: python-check-blanket-noqa - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.3.0 + rev: v4.5.0 hooks: - id: check-merge-conflict - id: check-yaml diff --git a/jsonmodels/errors.py b/jsonmodels/errors.py index d8b9bdf..43c6b0b 100644 --- a/jsonmodels/errors.py +++ b/jsonmodels/errors.py @@ -1,13 +1,10 @@ class ValidationError(RuntimeError): - pass class FieldNotFound(RuntimeError): - pass class FieldNotSupported(ValueError): - pass diff --git a/setup.py b/setup.py index 2751208..31cafe5 100755 --- a/setup.py +++ b/setup.py @@ -15,7 +15,6 @@ class PyTest(TestCommand): - user_options = [("pytest-args=", "a", "Arguments to pass to py.test")] def initialize_options(self): diff --git a/tests/test_circular_references.py b/tests/test_circular_references.py index a594668..98c9c34 100644 --- a/tests/test_circular_references.py +++ b/tests/test_circular_references.py @@ -5,13 +5,11 @@ class Primary(models.Base): - name = fields.StringField() secondary = fields.EmbeddedField("Secondary") class Secondary(models.Base): - data = fields.IntField() first = fields.EmbeddedField("Primary") @@ -24,19 +22,16 @@ def test_generate_circular_schema(): class File(models.Base): - name = fields.StringField() size = fields.FloatField() class Directory(models.Base): - name = fields.StringField() children = fields.ListField(["Directory", File]) class Filesystem(models.Base): - name = fields.StringField() children = fields.ListField([Directory, File]) diff --git a/tests/test_data_initialization.py b/tests/test_data_initialization.py index 783f623..d961b96 100644 --- a/tests/test_data_initialization.py +++ b/tests/test_data_initialization.py @@ -7,7 +7,6 @@ def test_initialization(): class Person(models.Base): - name = fields.StringField() surname = fields.StringField() age = fields.IntField() @@ -38,12 +37,10 @@ class Person(models.Base): def test_deep_initialization(): class Car(models.Base): - brand = fields.StringField() extra = fields.DictField() class ParkingPlace(models.Base): - location = fields.StringField() car = fields.EmbeddedField(Car) @@ -89,15 +86,12 @@ class ParkingPlace(models.Base): def test_deep_initialization_error_with_multitypes(): class Viper(models.Base): - brand = fields.StringField() class Lamborghini(models.Base): - brand = fields.StringField() class ParkingPlace(models.Base): - location = fields.StringField() car = fields.EmbeddedField([Viper, Lamborghini]) @@ -113,11 +107,9 @@ class ParkingPlace(models.Base): def test_deep_initialization_with_list(): class Car(models.Base): - brand = fields.StringField() class Parking(models.Base): - location = fields.StringField() cars = fields.ListField(items_types=Car) @@ -156,15 +148,12 @@ class Parking(models.Base): def test_deep_initialization_error_with_list_and_multitypes(): class Viper(models.Base): - brand = fields.StringField() class Lamborghini(models.Base): - brand = fields.StringField() class Parking(models.Base): - location = fields.StringField() cars = fields.ListField([Viper, Lamborghini]) @@ -193,15 +182,12 @@ class Parking(models.Base): def test_deep_initialization_error_when_result_non_iterable(): class Viper(models.Base): - brand = fields.StringField() class Lamborghini(models.Base): - brand = fields.StringField() class Parking(models.Base): - location = fields.StringField() cars = fields.ListField([Viper, Lamborghini]) @@ -220,7 +206,6 @@ class Parking(models.Base): def test_initialization_with_non_models_types(): class Person(models.Base): - names = fields.ListField(str) surname = fields.StringField() @@ -239,7 +224,6 @@ class Person(models.Base): def test_initialization_with_multi_non_models_types(): class Person(models.Base): - name = fields.StringField() mix = fields.ListField((str, float)) @@ -259,7 +243,6 @@ class Person(models.Base): def test_initialization_with_wrong_types(): class Person(models.Base): - name = fields.StringField() mix = fields.ListField((str, float)) @@ -270,11 +253,9 @@ class Person(models.Base): def test_deep_initialization_for_embed_field(): class Car(models.Base): - brand = fields.StringField() class ParkingPlace(models.Base): - location = fields.StringField() car = fields.EmbeddedField(Car) diff --git a/tests/test_datetime_fields.py b/tests/test_datetime_fields.py index be5533f..a2c839e 100644 --- a/tests/test_datetime_fields.py +++ b/tests/test_datetime_fields.py @@ -30,7 +30,6 @@ def dst(self, dt): def test_time_field(): class Event(models.Base): - time = fields.TimeField() event = Event() @@ -42,7 +41,6 @@ class Event(models.Base): def test_time_field_not_required(): class Event(models.Base): - time = fields.TimeField(required=False) event = Event() @@ -52,7 +50,6 @@ class Event(models.Base): def test_time_field_to_struct(): - field = fields.TimeField() assert field.str_format is None @@ -65,7 +62,6 @@ def test_time_field_to_struct(): def test_base_field_to_struct(): - field = fields.BaseField() assert field.to_struct(True) is True assert field.to_struct(False) is False @@ -74,7 +70,6 @@ def test_base_field_to_struct(): def test_time_field_to_struct_with_format(): - field = fields.TimeField(str_format="%H:%M") assert "%H:%M" == field.str_format @@ -87,7 +82,6 @@ def test_time_field_to_struct_with_format(): def test_time_field_to_struct_with_tz(): - field = fields.TimeField() tt = datetime.time(tzinfo=_TestCet()) @@ -104,7 +98,6 @@ def test_time_field_to_struct_with_tz(): def test_time_field_format_has_precedence(): - field = fields.TimeField(str_format="%H:%M") tt = datetime.time(12, 34, 56, tzinfo=_TestCet()) @@ -112,7 +105,6 @@ def test_time_field_format_has_precedence(): def test_time_field_parse_value(): - field = fields.TimeField() assert datetime.time() == field.parse_value("00:00:00") @@ -126,7 +118,6 @@ def test_time_field_parse_value(): def test_date_field(): class Event(models.Base): - date = fields.DateField() event = Event() @@ -138,7 +129,6 @@ class Event(models.Base): def test_date_field_not_required(): class Event(models.Base): - date = fields.DateField(required=False) event = Event() @@ -148,7 +138,6 @@ class Event(models.Base): def test_date_field_to_struct(): - field = fields.DateField() assert field.str_format is None @@ -161,7 +150,6 @@ def test_date_field_to_struct(): def test_date_field_to_struct_with_format(): - field = fields.DateField(str_format="%Y/%m/%d") assert "%Y/%m/%d" == field.str_format @@ -171,7 +159,6 @@ def test_date_field_to_struct_with_format(): def test_date_field_parse_value(): - field = fields.DateField() assert datetime.date(2012, 12, 21) == field.parse_value("2012-12-21") @@ -183,7 +170,6 @@ def test_date_field_parse_value(): def test_datetime_field(): class Event(models.Base): - date = fields.DateTimeField() event = Event() @@ -195,7 +181,6 @@ class Event(models.Base): def test_datetime_field_not_required(): class Event(models.Base): - date = fields.DateTimeField() event = Event() @@ -204,7 +189,6 @@ class Event(models.Base): def test_datetime_field_to_struct(): - field = fields.DateTimeField() assert field.str_format is None @@ -214,7 +198,6 @@ def test_datetime_field_to_struct(): def test_datetime_field_to_struct_with_format(): - field = fields.TimeField(str_format="%H:%M %Y/%m") assert "%H:%M %Y/%m" == field.str_format @@ -224,7 +207,6 @@ def test_datetime_field_to_struct_with_format(): def test_datetime_field_to_struct_with_tz(): - field = fields.DateTimeField() tt = datetime.datetime(2014, 5, 7, 12, 45, 56, tzinfo=_TestCet()) @@ -235,7 +217,6 @@ def test_datetime_field_to_struct_with_tz(): def test_datetime_field_format_has_precedence(): - field = fields.DateTimeField(str_format="%H:%M %Y/%m") tt = datetime.datetime(2014, 5, 7, 12, 45, 56, tzinfo=_TestCet()) @@ -243,7 +224,6 @@ def test_datetime_field_format_has_precedence(): def test_datetime_field_parse_value(): - field = fields.DateTimeField() assert datetime.datetime(2014, 4, 21, 12, 45, 56) == field.parse_value( diff --git a/tests/test_fields.py b/tests/test_fields.py index f0f53b4..92e9fa9 100644 --- a/tests/test_fields.py +++ b/tests/test_fields.py @@ -2,11 +2,9 @@ def test_bool_field(): - field = fields.BoolField() class Person(models.Base): - is_programmer = field person = Person() @@ -31,7 +29,6 @@ class Person(models.Base): def test_dict_field(): - field = fields.DictField() default_field = fields.DictField( default={"extra_default": "Hello", "deep_extra": {"spanish": "Hola"}}, @@ -39,7 +36,6 @@ def test_dict_field(): ) class Person(models.Base): - extra = field extra_required = fields.DictField(required=True) extra_default = default_field diff --git a/tests/test_jsonmodels.py b/tests/test_jsonmodels.py index 6b04dbf..3f4b86a 100644 --- a/tests/test_jsonmodels.py +++ b/tests/test_jsonmodels.py @@ -5,7 +5,6 @@ def test_model1(): class Person(models.Base): - name = fields.StringField() surname = fields.StringField() age = fields.IntField() @@ -21,7 +20,6 @@ class Person(models.Base): def test_required(): class Person(models.Base): - name = fields.StringField(required=True) surname = fields.StringField() age = fields.IntField() @@ -36,7 +34,6 @@ class Person(models.Base): def test_type_validation(): class Person(models.Base): - name = fields.StringField() age = fields.IntField() @@ -47,7 +44,6 @@ class Person(models.Base): def test_base_field_should_not_be_usable(): class Person(models.Base): - name = fields.BaseField() alan = Person() @@ -61,7 +57,6 @@ class Person(models.Base): def test_value_replacements(): class Person(models.Base): - name = fields.StringField() age = fields.IntField() cash = fields.FloatField() @@ -76,7 +71,6 @@ class Person(models.Base): def test_list_field(): class Car(models.Base): - wheels = fields.ListField() viper = Car() @@ -95,7 +89,6 @@ class Wheel2(models.Base): pass class Car(models.Base): - wheels = fields.ListField(items_types=[Wheel]) viper = Car() @@ -115,7 +108,6 @@ class Wheel2(models.Base): pass class Car(models.Base): - wheels = fields.ListField(items_types=[Wheel]) viper = Car() @@ -138,7 +130,6 @@ class Lamborghini(Car): pass class Garage1(models.Base): - cars = fields.ListField(items_types=[Car]) garage = Garage1() @@ -147,7 +138,6 @@ class Garage1(models.Base): garage.cars.append(Lamborghini()) class Garage2(models.Base): - cars = fields.ListField(items_types=[Viper, Lamborghini]) garage = Garage2() @@ -160,7 +150,6 @@ class Garage2(models.Base): def test_list_validation(): class Garage(models.Base): - cars = fields.ListField() garage = Garage() @@ -171,11 +160,9 @@ class Garage(models.Base): def test_embedded_model(): class Secondary(models.Base): - data = fields.IntField() class Primary(models.Base): - name = fields.StringField() secondary = fields.EmbeddedField(Secondary) @@ -193,11 +180,9 @@ class Primary(models.Base): def test_embedded_required_validation(): class Secondary(models.Base): - data = fields.IntField(required=True) class Primary(models.Base): - name = fields.StringField() secondary = fields.EmbeddedField(Secondary) @@ -212,7 +197,6 @@ class Primary(models.Base): entity.secondary = None class Primary(models.Base): - name = fields.StringField() secondary = fields.EmbeddedField(Secondary, required=True) @@ -236,7 +220,6 @@ class Lamborghini(Car): pass class ParkingPlace(models.Base): - location = fields.StringField() car = fields.EmbeddedField([Viper, Lamborghini]) @@ -249,7 +232,6 @@ class ParkingPlace(models.Base): place.car = Car() class ParkingPlace(models.Base): - location = fields.StringField() car = fields.EmbeddedField(Car) @@ -262,7 +244,6 @@ class ParkingPlace(models.Base): def test_iterable(): class Person(models.Base): - name = fields.StringField() surname = fields.StringField() age = fields.IntField() @@ -290,13 +271,11 @@ class Person(models.Base): def test_get_field(): - name_field = fields.StringField() surname_field = fields.StringField() age_field = fields.IntField() class Person(models.Base): - name = name_field surname = surname_field age = age_field @@ -310,7 +289,6 @@ class Person(models.Base): def test_repr(): class Person(models.Base): - name = fields.StringField() surname = fields.StringField() age = fields.IntField() @@ -321,7 +299,6 @@ class Person(models.Base): assert chuck.__str__() == "Person object" class Person2(models.Base): - name = fields.StringField() surname = fields.StringField() age = fields.IntField() @@ -345,7 +322,6 @@ def __str__(self): def test_list_field_with_non_model_types(): class Person(models.Base): - names = fields.ListField(str) surname = fields.StringField() @@ -356,7 +332,6 @@ class Person(models.Base): def test_help_text(): class Person(models.Base): - name = fields.StringField(help_text="Name of person.") age = fields.IntField(help_text="Age of person.") @@ -406,11 +381,9 @@ class Person2: def test_required_embedded_field(): class Secondary(models.Base): - data = fields.IntField() class Primary(models.Base): - name = fields.StringField() secondary = fields.EmbeddedField(Secondary, required=True) @@ -421,7 +394,6 @@ class Primary(models.Base): entity.validate() class Primary(models.Base): - name = fields.StringField() secondary = fields.EmbeddedField(Secondary, required=False) @@ -437,7 +409,6 @@ class Wheel(models.Base): pass class Car(models.Base): - wheels = fields.ListField(items_types=[Wheel]) viper = Car() @@ -505,7 +476,6 @@ class Wheel(models.Base): pressure = fields.FloatField() class Car(models.Base): - wheels = fields.ListField(items_types=[Wheel]) car = Car( diff --git a/tests/test_lazy_loading.py b/tests/test_lazy_loading.py index 560f31a..4c7b3e6 100644 --- a/tests/test_lazy_loading.py +++ b/tests/test_lazy_loading.py @@ -4,49 +4,41 @@ class Primary(models.Base): - name = fields.StringField() secondary = fields.EmbeddedField("Secondary") class Third(models.Base): - name = fields.StringField() secondary = fields.EmbeddedField("tests.test_lazy_loading.Secondary") class Fourth(models.Base): - name = fields.StringField() secondary = fields.EmbeddedField(".Secondary") class Fifth(models.Base): - name = fields.StringField() secondary = fields.EmbeddedField("..test_lazy_loading.Secondary") class Sixth(models.Base): - name = fields.StringField() secondary = fields.EmbeddedField("...tests.test_lazy_loading.Secondary") class Seventh(models.Base): - name = fields.StringField() secondary = fields.EmbeddedField("....tests.test_lazy_loading.Secondary") class Eighth(models.Base): - name = fields.StringField() secondary = fields.EmbeddedField(".SomeWrongEntity") class Secondary(models.Base): - data = fields.IntField() @@ -84,13 +76,11 @@ def test_wrong_entity(): class File(models.Base): - name = fields.StringField() size = fields.FloatField() class Directory(models.Base): - name = fields.StringField() children = fields.ListField(["Directory", File]) diff --git a/tests/test_memory_usage.py b/tests/test_memory_usage.py index 2c375bf..f04ad03 100644 --- a/tests/test_memory_usage.py +++ b/tests/test_memory_usage.py @@ -7,7 +7,6 @@ class User(Base): - name = StringField() diff --git a/tests/test_name.py b/tests/test_name.py index ca0f8df..e116604 100644 --- a/tests/test_name.py +++ b/tests/test_name.py @@ -5,7 +5,6 @@ def test_fields_can_have_different_names(): class Human(models.Base): - name = fields.StringField() surname = fields.StringField(name="second-name") @@ -24,7 +23,6 @@ def test_only_subset_of_names_is_accepted(): def test_load_data_from_structure_names(): class Human(models.Base): - name = fields.StringField() surname = fields.StringField(name="second-name") @@ -40,7 +38,6 @@ class Human(models.Base): def test_names_duplicates_are_invalid(): - with pytest.raises(ValueError): class Human(models.Base): @@ -76,12 +73,10 @@ class Product(models.Base): def test_nested_data(): class Pet(models.Base): - name = fields.StringField(required=True, name="pets_name") age = fields.IntField() class Human(models.Base): - name = fields.StringField() pet = fields.EmbeddedField(Pet, name="owned-pet") @@ -92,7 +87,6 @@ class Human(models.Base): def test_cross_names(): class Foo(models.Base): - one = fields.IntField(name="two") two = fields.IntField(name="one") diff --git a/tests/test_schema.py b/tests/test_schema.py index 14bccb2..631feb4 100644 --- a/tests/test_schema.py +++ b/tests/test_schema.py @@ -8,7 +8,6 @@ def test_model1(): class Person(models.Base): - name = fields.StringField(required=True) surname = fields.StringField(required=True) age = fields.IntField() @@ -23,24 +22,20 @@ class Person(models.Base): def test_model2(): class Car(models.Base): - brand = fields.StringField(required=True) registration = fields.StringField(required=True) extra = fields.DictField(required=True) class Toy(models.Base): - name = fields.StringField(required=True) class Kid(models.Base): - name = fields.StringField(required=True) surname = fields.StringField(required=True) age = fields.IntField() toys = fields.ListField(Toy) class Person(models.Base): - name = fields.StringField(required=True) surname = fields.StringField(required=True) age = fields.IntField() @@ -56,32 +51,26 @@ class Person(models.Base): def test_model3(): class Viper(models.Base): - brand = fields.StringField() capacity = fields.FloatField() class Lamborghini(models.Base): - brand = fields.StringField() velocity = fields.FloatField() class PC(models.Base): - name = fields.StringField() ports = fields.StringField() class Laptop(models.Base): - name = fields.StringField() battery_voltage = fields.FloatField() class Tablet(models.Base): - name = fields.StringField() os = fields.StringField() class Person(models.Base): - name = fields.StringField(required=True) surname = fields.StringField(required=True) age = fields.IntField() @@ -137,7 +126,6 @@ def __init__(self, some_value): def test_datetime_fields(): class Event(models.Base): - time = fields.TimeField() date = fields.DateField() end = fields.DateTimeField() @@ -150,7 +138,6 @@ class Event(models.Base): def test_bool_field(): class Person(models.Base): - has_childen = fields.BoolField() schema = Person.to_json_schema() @@ -161,11 +148,9 @@ class Person(models.Base): def test_unsupported_field(): class NewField(fields.BaseField): - pass class Person(models.Base): - some_property = NewField() with pytest.raises(errors.FieldNotSupported): @@ -184,7 +169,6 @@ def function_validator(value): raise RuntimeError() class Person(models.Base): - name = fields.StringField(validators=ClassBasedValidator()) surname = fields.StringField(validators=function_validator) @@ -197,7 +181,6 @@ class Person(models.Base): def test_min_validator(): class Person(models.Base): - name = fields.StringField() surname = fields.StringField() age = fields.IntField(validators=validators.Min(18)) @@ -210,7 +193,6 @@ class Person(models.Base): def test_min_validator_with_exclusive(): class Person(models.Base): - name = fields.StringField() surname = fields.StringField() age = fields.IntField(validators=validators.Min(18, True)) @@ -223,7 +205,6 @@ class Person(models.Base): def test_max_validator(): class Person(models.Base): - name = fields.StringField() surname = fields.StringField() age = fields.IntField(validators=validators.Max(18)) @@ -236,7 +217,6 @@ class Person(models.Base): def test_max_validator_with_exclusive(): class Person(models.Base): - name = fields.StringField() surname = fields.StringField() age = fields.IntField(validators=validators.Max(18, True)) @@ -249,7 +229,6 @@ class Person(models.Base): def test_regex_validator(): class Person(models.Base): - name = fields.StringField(validators=validators.Regex("^some pattern$")) schema = Person.to_json_schema() @@ -260,7 +239,6 @@ class Person(models.Base): def test_regex_validator_when_ecma_regex_given(): class Person(models.Base): - name = fields.StringField(validators=validators.Regex("/^some pattern$/")) schema = Person.to_json_schema() @@ -271,7 +249,6 @@ class Person(models.Base): def test_regex_validator_with_flag(): class Person(models.Base): - name = fields.StringField( validators=validators.Regex("^some pattern$", ignorecase=True) ) @@ -284,7 +261,6 @@ class Person(models.Base): def test_length_validator_min(): class Person(models.Base): - name = fields.StringField(validators=validators.Length(5)) surname = fields.StringField() age = fields.IntField() @@ -297,7 +273,6 @@ class Person(models.Base): def test_length_validator(): class Person(models.Base): - name = fields.StringField(validators=validators.Length(5, 20)) surname = fields.StringField() age = fields.IntField() @@ -348,7 +323,6 @@ class Person(models.Base): def test_max_only_validator(): class Person(models.Base): - name = fields.StringField(validators=validators.Length(maximum_value=20)) surname = fields.StringField() age = fields.IntField() @@ -361,13 +335,11 @@ class Person(models.Base): def test_schema_for_list_and_primitives(): class Event(models.Base): - time = fields.TimeField() date = fields.DateField() end = fields.DateTimeField() class Person(models.Base): - names = fields.ListField([str, int, float, bool, Event]) schema = Person.to_json_schema() @@ -378,7 +350,6 @@ class Person(models.Base): def test_schema_for_unsupported_primitive(): class Person(models.Base): - names = fields.ListField([str, object]) with pytest.raises(errors.FieldNotSupported): diff --git a/tests/test_struct.py b/tests/test_struct.py index 7de2193..a3ce15b 100644 --- a/tests/test_struct.py +++ b/tests/test_struct.py @@ -6,13 +6,11 @@ class _DateField(fields.BaseField): - _types = (datetime,) def test_to_struct_basic(): class Person(models.Base): - name = fields.StringField(required=True) surname = fields.StringField(required=True) age = fields.IntField() @@ -44,12 +42,10 @@ class Person(models.Base): def test_to_struct_nested_1(): class Car(models.Base): - brand = fields.StringField() extra = fields.DictField() class ParkingPlace(models.Base): - location = fields.StringField() car = fields.EmbeddedField(Car) @@ -74,15 +70,12 @@ class ParkingPlace(models.Base): def test_to_struct_nested_2(): class Viper(models.Base): - serial = fields.StringField() class Lamborghini(models.Base): - serial = fields.StringField() class Parking(models.Base): - location = fields.StringField() cars = fields.ListField([Viper, Lamborghini]) @@ -113,7 +106,6 @@ class Parking(models.Base): def test_to_struct_with_non_models_types(): class Person(models.Base): - names = fields.ListField(str) surname = fields.StringField() @@ -137,7 +129,6 @@ class Person(models.Base): def test_to_struct_with_multi_non_models_types(): class Person(models.Base): - name = fields.StringField() mix = fields.ListField((str, float)) diff --git a/tests/test_validation.py b/tests/test_validation.py index aaf3247..a031023 100644 --- a/tests/test_validation.py +++ b/tests/test_validation.py @@ -20,7 +20,6 @@ def assert_called_once_with(self, value): def test_validation(): - validator1 = FakeValidator() validator2 = FakeValidator() @@ -32,7 +31,6 @@ def validator3(value): arg.append(value) class Person(models.Base): - name = fields.StringField(required=True, validators=[validator1, validator2]) surname = fields.StringField(required=True) age = fields.IntField(validators=validator3) @@ -53,7 +51,6 @@ class Person(models.Base): def test_validators_are_always_iterable(): class Person(models.Base): - children = fields.ListField() alan = Person() @@ -63,7 +60,6 @@ class Person(models.Base): def test_get_field_not_found(): class Person(models.Base): - children = fields.ListField() alan = Person() @@ -73,7 +69,6 @@ class Person(models.Base): def test_min_validation(): - validator = validators.Min(3) assert 3 == validator.minimum_value @@ -87,7 +82,6 @@ def test_min_validation(): def test_exclusive_validation(): - validator = validators.Min(3, True) assert 3 == validator.minimum_value @@ -101,7 +95,6 @@ def test_exclusive_validation(): def test_max_validation(): - validator = validators.Max(42) assert 42 == validator.maximum_value @@ -114,7 +107,6 @@ def test_max_validation(): def test_max_exclusive_validation(): - validator = validators.Max(42, True) assert 42 == validator.maximum_value @@ -128,7 +120,6 @@ def test_max_exclusive_validation(): def test_regex_validation(): - validator = validators.Regex("some") assert "some" == validator.pattern @@ -164,7 +155,6 @@ def test_regex_validation_flags(): def test_regex_validation_for_wrong_type(): - validator = validators.Regex("some") assert "some" == validator.pattern @@ -173,7 +163,6 @@ def test_regex_validation_for_wrong_type(): def test_validation_2(): - validator = validators.Regex("^some[0-9]$") assert "^some[0-9]$" == validator.pattern @@ -212,7 +201,6 @@ def test_validation_multiline(): def test_regex_validator(): class Person(models.Base): - name = fields.StringField( validators=validators.Regex("^[a-z]+$", ignorecase=True) ) @@ -227,7 +215,6 @@ class Person(models.Base): def test_regex_validator_when_ecma_regex_given(): class Person(models.Base): - name = fields.StringField( validators=validators.Regex("/^[a-z]+$/i", ignorecase=False) )