Mercurial > p > roundup > code
comparison roundup/password.py @ 7177:d787f7282ea3
Move imports to top of file out of test code path.
See if this helps with time regression under python2.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Sun, 26 Feb 2023 11:06:04 -0500 |
| parents | f6b24a8524cd |
| children | 2de72f75f2f8 |
comparison
equal
deleted
inserted
replaced
| 7176:4c9acc580769 | 7177:d787f7282ea3 |
|---|---|
| 17 # | 17 # |
| 18 """Password handling (encoding, decoding). | 18 """Password handling (encoding, decoding). |
| 19 """ | 19 """ |
| 20 __docformat__ = 'restructuredtext' | 20 __docformat__ = 'restructuredtext' |
| 21 | 21 |
| 22 import os | |
| 22 import re | 23 import re |
| 23 import string | 24 import string |
| 25 import sys | |
| 24 import warnings | 26 import warnings |
| 25 | 27 |
| 26 from base64 import b64encode, b64decode | 28 from base64 import b64encode, b64decode |
| 27 from hashlib import md5, sha1 | 29 from hashlib import md5, sha1 |
| 28 | 30 |
| 190 raw_salt = random_.token_bytes(20) | 192 raw_salt = random_.token_bytes(20) |
| 191 salt = h64encode(raw_salt) | 193 salt = h64encode(raw_salt) |
| 192 if config: | 194 if config: |
| 193 rounds = config.PASSWORD_PBKDF2_DEFAULT_ROUNDS | 195 rounds = config.PASSWORD_PBKDF2_DEFAULT_ROUNDS |
| 194 else: | 196 else: |
| 195 import os | |
| 196 import sys | |
| 197 if ("pytest" in sys.modules and | 197 if ("pytest" in sys.modules and |
| 198 "PYTEST_CURRENT_TEST" in os.environ): | 198 "PYTEST_CURRENT_TEST" in os.environ): |
| 199 # Set rounds to 1000 if no config is passed and | 199 # Set rounds to 1000 if no config is passed and |
| 200 # we are running within a pytest test. Using | 200 # we are running within a pytest test. Using |
| 201 # actual 2M production values makes testing | 201 # actual 2M production values makes testing |
