Fix formatting and resolve pre-commit errors

This commit is contained in:
Ghosts6 2024-10-19 20:04:02 +01:00
parent 75e1c02019
commit 1a50ea4f9d
2 changed files with 7 additions and 7 deletions

View File

@ -917,7 +917,7 @@ class CustomLengthValidator:
def __call__(self, value): def __call__(self, value):
if len(value) < self.min_length: if len(value) < self.min_length:
raise ValueError(f"This field must be at least {self.min_length} characters long.") raise ValueError(f"This field must be at least {self.min_length} characters long.")
if self.max_length is not None and len(value) > self.max_length: if self.max_length is not None and len(value) > self.max_length:
raise ValueError(f"This field must be no more than {self.max_length} characters long.") raise ValueError(f"This field must be no more than {self.max_length} characters long.")

View File

@ -1071,7 +1071,7 @@ class TestAlphabeticField:
invalid_inputs = { invalid_inputs = {
'John123': ['This field must contain only alphabetic characters and spaces.'], 'John123': ['This field must contain only alphabetic characters and spaces.'],
'Alice!': ['This field must contain only alphabetic characters and spaces.'], 'Alice!': ['This field must contain only alphabetic characters and spaces.'],
'': ['This field must contain only alphabetic characters and spaces.'], '': ['This field must contain only alphabetic characters and spaces.'],
} }
non_string_inputs = [ non_string_inputs = [
123, # Integer 123, # Integer
@ -1085,7 +1085,7 @@ class TestAlphabeticField:
def test_valid_inputs(self): def test_valid_inputs(self):
validator = AlphabeticFieldValidator() validator = AlphabeticFieldValidator()
for value in self.valid_inputs.keys(): for value in self.valid_inputs.keys():
validator(value) validator(value)
def test_invalid_inputs(self): def test_invalid_inputs(self):
validator = AlphabeticFieldValidator() validator = AlphabeticFieldValidator()
@ -1111,7 +1111,7 @@ class TestAlphanumericField:
invalid_inputs = { invalid_inputs = {
'John!': ['This field must contain only alphanumeric characters (letters and numbers).'], 'John!': ['This field must contain only alphanumeric characters (letters and numbers).'],
'Alice 007': ['This field must contain only alphanumeric characters (letters and numbers).'], 'Alice 007': ['This field must contain only alphanumeric characters (letters and numbers).'],
'': ['This field must contain only alphanumeric characters (letters and numbers).'], '': ['This field must contain only alphanumeric characters (letters and numbers).'],
} }
non_string_inputs = [ non_string_inputs = [
123, # Integer 123, # Integer
@ -1125,7 +1125,7 @@ class TestAlphanumericField:
def test_valid_inputs(self): def test_valid_inputs(self):
validator = AlphanumericFieldValidator() validator = AlphanumericFieldValidator()
for value in self.valid_inputs.keys(): for value in self.valid_inputs.keys():
validator(value) validator(value)
def test_invalid_inputs(self): def test_invalid_inputs(self):
validator = AlphanumericFieldValidator() validator = AlphanumericFieldValidator()
@ -1153,12 +1153,12 @@ class TestCustomLengthField:
'ab': ['This field must be at least 3 characters long.'], # Too short 'ab': ['This field must be at least 3 characters long.'], # Too short
'abcdefghijk': ['This field must be no more than 10 characters long.'], # Too long 'abcdefghijk': ['This field must be no more than 10 characters long.'], # Too long
} }
field = str field = str
def test_valid_inputs(self): def test_valid_inputs(self):
validator = CustomLengthValidator(min_length=3, max_length=10) validator = CustomLengthValidator(min_length=3, max_length=10)
for value in self.valid_inputs.keys(): for value in self.valid_inputs.keys():
validator(value) validator(value)
def test_invalid_inputs(self): def test_invalid_inputs(self):
validator = CustomLengthValidator(min_length=3, max_length=10) validator = CustomLengthValidator(min_length=3, max_length=10)