summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2015-06-16 11:02:27 -0400
committerTim Graham <timograham@gmail.com>2015-06-16 11:02:27 -0400
commit09f2cdbe1a43e79e31f5ea509b59d4c87db29832 (patch)
tree85b8303dd7c56ab478bbe9c2fcc0a4a2b30674db
parente6dd7f995a5a785a5aa12378df209314b1d77d93 (diff)
Refs #16860 -- Fixed a resource and deprecation warning in password validation.
-rw-r--r--django/contrib/auth/password_validation.py4
-rw-r--r--tests/auth_tests/test_validators.py2
2 files changed, 4 insertions, 2 deletions
diff --git a/django/contrib/auth/password_validation.py b/django/contrib/auth/password_validation.py
index f01c13d841..efad0d72a6 100644
--- a/django/contrib/auth/password_validation.py
+++ b/django/contrib/auth/password_validation.py
@@ -161,7 +161,9 @@ class CommonPasswordValidator(object):
try:
common_passwords_lines = gzip.open(password_list_path).read().decode('utf-8').splitlines()
except IOError:
- common_passwords_lines = open(password_list_path).readlines()
+ with open(password_list_path) as f:
+ common_passwords_lines = f.readlines()
+
self.passwords = {p.strip() for p in common_passwords_lines}
def validate(self, password, user=None):
diff --git a/tests/auth_tests/test_validators.py b/tests/auth_tests/test_validators.py
index 3822c9c675..e70feb727d 100644
--- a/tests/auth_tests/test_validators.py
+++ b/tests/auth_tests/test_validators.py
@@ -41,7 +41,7 @@ class PasswordValidationTest(TestCase):
self.assertIsNone(validate_password('sufficiently-long'))
msg_too_short = 'This password is too short. It must contain at least 12 characters.'
- with self.assertRaises(ValidationError, args=['This password is too short.']) as cm:
+ with self.assertRaises(ValidationError) as cm:
validate_password('django4242')
self.assertEqual(cm.exception.messages, [msg_too_short])
self.assertEqual(cm.exception.error_list[0].code, 'password_too_short')