diff options
author | Eli Collins <elic@assurancetechnologies.com> | 2017-01-30 12:59:33 -0500 |
---|---|---|
committer | Eli Collins <elic@assurancetechnologies.com> | 2017-01-30 12:59:33 -0500 |
commit | 547545395959779c33a2bd2927d998bcde6781d0 (patch) | |
tree | e00c564287fc725047de42b1d2f31fe95a052149 | |
parent | 285f511cd2fff866686107170bef5a2fa532de66 (diff) | |
download | passlib-547545395959779c33a2bd2927d998bcde6781d0.tar.gz |
passlib.tests: silence some more scrypt backend warnings,
fix max_time_t to catch yet another utcfromtimestamp() error.
-rw-r--r-- | docs/history/1.7.rst | 6 | ||||
-rw-r--r-- | passlib/tests/test_crypto_scrypt.py | 1 | ||||
-rw-r--r-- | passlib/tests/test_totp.py | 15 |
3 files changed, 16 insertions, 6 deletions
diff --git a/docs/history/1.7.rst b/docs/history/1.7.rst index f2a2cd1..07de239 100644 --- a/docs/history/1.7.rst +++ b/docs/history/1.7.rst @@ -19,9 +19,9 @@ Bugfixes * setup.py: Prevent erroneous version strings when run from an sdist. This should fix some reproducible-build issues observed downstream. -* TOTP tests: Test suite now traps additional errors that :func:`datetime.utcfromtimestamp` - may throw under python 3, and works around python 3.6 bug `29100 <https://bugs.python.org/issue29100>`_. - This should fix some test failures under python 3.6 and certain bit-size architectures. +* :mod:`!passlib.tests.test_totp`: Test suite now traps additional errors that :func:`datetime.utcfromtimestamp` + may throw under python 3, which should fix some test failures on architectures with rarer ILP sizes. + It also works around Python 3.6 bug `29100 <https://bugs.python.org/issue29100>`_. Deprecations ------------ diff --git a/passlib/tests/test_crypto_scrypt.py b/passlib/tests/test_crypto_scrypt.py index 8c307f9..9666667 100644 --- a/passlib/tests/test_crypto_scrypt.py +++ b/passlib/tests/test_crypto_scrypt.py @@ -8,6 +8,7 @@ import hashlib import logging; log = logging.getLogger(__name__) import struct import warnings +warnings.filterwarnings("ignore", ".*using builtin scrypt backend.*") # site # pkg from passlib import exc diff --git a/passlib/tests/test_totp.py b/passlib/tests/test_totp.py index 54a9d91..1229da7 100644 --- a/passlib/tests/test_totp.py +++ b/passlib/tests/test_totp.py @@ -76,19 +76,28 @@ def _get_max_time_t(): # * int out of range for host's time_t: # py2 throws ValueError, py3 throws OverflowError. # - return value-1 + break # Workaround for python 3.6.0 issue -- # Instead of throwing ValueError if year out of range for datetime, # Python 3.6 will do some weird behavior that masks high bits # e.g. (1<<40) -> year 36812, but (1<<41) -> year 6118. - # (Filed as bug -- http://bugs.python.org/issue29346) + # (Appears to be bug http://bugs.python.org/issue29100) # This check stops at largest non-wrapping bit size. if next_year < year: - return value-1 + break value = next_value + # 'value-1' is maximum. + value -= 1 + + # check for crazy case where we're beyond what datetime supports + # (caused by bug 29100 again). compare to max value that datetime + # module supports -- datetime.datetime(9999, 12, 31, 23, 59, 59, 999999) + max_datetime_timestamp = 253402318800 + return min(value, max_datetime_timestamp) + #: Rough approximation of max value acceptable by hosts's time_t. #: This is frequently ~2**37 on 64 bit, and ~2**31 on 32 bit systems. max_time_t = _get_max_time_t() |