From 8624459586c7916e0a5550ed03af60afa44cf387 Mon Sep 17 00:00:00 2001 From: Alexey Date: Wed, 19 Sep 2018 12:03:02 +0100 Subject: [PATCH] Added a test for password_changed() with a custom validator. --- tests/auth_tests/test_validators.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/auth_tests/test_validators.py b/tests/auth_tests/test_validators.py index d43efc6a3c..e50da39663 100644 --- a/tests/auth_tests/test_validators.py +++ b/tests/auth_tests/test_validators.py @@ -57,6 +57,18 @@ class PasswordValidationTest(TestCase): def test_password_changed(self): self.assertIsNone(password_changed('password')) + def test_password_changed_with_custom_validator(self): + class Validator: + def password_changed(self, password, user): + self.password = password + self.user = user + + user = object() + validator = Validator() + password_changed('password', user=user, password_validators=(validator,)) + self.assertIs(validator.user, user) + self.assertEqual(validator.password, 'password') + def test_password_validators_help_texts(self): help_texts = password_validators_help_texts() self.assertEqual(len(help_texts), 2)