-
-
Notifications
You must be signed in to change notification settings - Fork 31.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update validators.py #18284
base: main
Are you sure you want to change the base?
Update validators.py #18284
Conversation
Fix unnecessary lazy evaluation in BaseValidator
Alternatively the |
This would be a change in behaviour, for example: MinValidator(0, message="") Will now override the message, while before it wouldn't. It appears there's nothing depending on that behaviour in Django's test suite, and it seems like reasonable behaviour, but someone might be depending on the old behaviour. Adding tests will help clear up the behaviour and prevent future regressions. |
I see your point but if you examine the file mentioned, all other validator classes use |
@jaap3 I tried adding test cases in class TestGetTextLazy(SimpleTestCase):
def test_min_value(self):
print('hi')
print(_('hello')) It runs with no problems whatsoever. Can you help me where I can test django so it is not already setup and apps are not loaded? |
Can anyone please check this pull request? |
@jaap3 Can you please check this? |
Sorry, I don't know how to get a testcase working for this. |
Fix unnecessary lazy evaluation in BaseValidator
Trac ticket number
ticket-N/A
Branch description
if you run this:
This will raise:
And the problem is this line because it tries to evaluate message instead of checking if it is None. This PR will solve this issue
Checklist
main
branch.