diff options
| author | Eli Collins <elic@assurancetechnologies.com> | 2011-12-06 12:48:04 -0500 |
|---|---|---|
| committer | Eli Collins <elic@assurancetechnologies.com> | 2011-12-06 12:48:04 -0500 |
| commit | 5fd5a76fdb58a26d101493f39f8256fc5c20e1c9 (patch) | |
| tree | f7e0fdeb34dafcc28f6ba2c859212a12b625a8e6 /passlib/tests | |
| parent | d07f2084c1532c121935cebf92cdbdd41c43bb57 (diff) | |
| download | passlib-5fd5a76fdb58a26d101493f39f8256fc5c20e1c9.tar.gz | |
replaced xrange() instances with compat.irange() alias
Diffstat (limited to 'passlib/tests')
| -rw-r--r-- | passlib/tests/test_apache.py | 5 | ||||
| -rw-r--r-- | passlib/tests/test_context.py | 13 | ||||
| -rw-r--r-- | passlib/tests/test_drivers.py | 9 | ||||
| -rw-r--r-- | passlib/tests/test_utils.py | 2 | ||||
| -rw-r--r-- | passlib/tests/utils.py | 4 |
5 files changed, 18 insertions, 15 deletions
diff --git a/passlib/tests/test_apache.py b/passlib/tests/test_apache.py index 3aec67c..0fb93a1 100644 --- a/passlib/tests/test_apache.py +++ b/passlib/tests/test_apache.py @@ -12,6 +12,7 @@ import time #pkg from passlib import apache from passlib.utils import b, native_str, bytes +from passlib.utils.compat import irange from passlib.tests.utils import TestCase, mktemp, gae_env, get_file, set_file #module log = getLogger(__name__) @@ -93,7 +94,7 @@ class HtpasswdFileTest(TestCase): "test verify()" ht = apache.HtpasswdFile._from_string(self.sample_01) self.assertTrue(ht.verify("user5","pass5") is None) - for i in xrange(1,5): + for i in irange(1,5): i = str(i) self.assertTrue(ht.verify("user"+i, "pass"+i)) self.assertTrue(ht.verify("user"+i, "pass5") is False) @@ -267,7 +268,7 @@ class HtdigestFileTest(TestCase): "test verify()" ht = apache.HtdigestFile._from_string(self.sample_01) self.assertTrue(ht.verify("user5", "realm","pass5") is None) - for i in xrange(1,5): + for i in irange(1,5): i = str(i) self.assertTrue(ht.verify("user"+i, "realm", "pass"+i)) self.assertTrue(ht.verify("user"+i, "realm", "pass5") is False) diff --git a/passlib/tests/test_context.py b/passlib/tests/test_context.py index 2d461d2..187dff4 100644 --- a/passlib/tests/test_context.py +++ b/passlib/tests/test_context.py @@ -19,6 +19,7 @@ except ImportError: from passlib import hash from passlib.context import CryptContext, CryptPolicy, LazyCryptContext from passlib.utils import to_bytes, to_unicode +from passlib.utils.compat import irange import passlib.utils.handlers as uh from passlib.tests.utils import TestCase, mktemp, catch_warnings, \ gae_env, set_file @@ -637,7 +638,7 @@ class CryptContextTest(TestCase): cc3 = CryptContext(policy=cc.policy.replace( bsdi_crypt__vary_rounds = 3)) seen = set() - for i in xrange(3*2*50): + for i in irange(3*2*50): h = cc3.genconfig("bsdi_crypt", salt="nacl") r = bc.from_string(h).rounds seen.add(r) @@ -651,7 +652,7 @@ class CryptContextTest(TestCase): cc4 = CryptContext(policy=cc.policy.replace( all__vary_rounds = "1%")) seen = set() - for i in xrange(30*50): + for i in irange(30*50): h = cc4.genconfig(salt="nacl") r = sc.from_string(h).rounds seen.add(r) @@ -869,19 +870,19 @@ class CryptContextTest(TestCase): "teset verify_and_update / hash_needs_update corrects bcrypt padding" # see issue 25. bcrypt = hash.bcrypt - + PASS1 = "loppux" BAD1 = "$2a$12$oaQbBqq8JnSM1NHRPQGXORm4GCUMqp7meTnkft4zgSnrbhoKdDV0C" GOOD1 = "$2a$12$oaQbBqq8JnSM1NHRPQGXOOm4GCUMqp7meTnkft4zgSnrbhoKdDV0C" ctx = CryptContext(["bcrypt"]) - + with catch_warnings(record=True) as wlog: warnings.simplefilter("always") self.assertTrue(ctx.hash_needs_update(BAD1)) self.assertFalse(ctx.hash_needs_update(GOOD1)) - - if bcrypt.has_backend(): + + if bcrypt.has_backend(): self.assertEquals(ctx.verify_and_update(PASS1,GOOD1), (True,None)) self.assertEquals(ctx.verify_and_update("x",BAD1), (False,None)) res = ctx.verify_and_update(PASS1, BAD1) diff --git a/passlib/tests/test_drivers.py b/passlib/tests/test_drivers.py index 1e40f86..f3a7079 100644 --- a/passlib/tests/test_drivers.py +++ b/passlib/tests/test_drivers.py @@ -10,6 +10,7 @@ import warnings #site #pkg from passlib import hash +from passlib.utils.compat import irange from passlib.tests.utils import TestCase, HandlerCase, create_backend_case, \ enable_option, b, catch_warnings #module @@ -163,9 +164,9 @@ class _BCryptTest(HandlerCase): # make sure genconfig & encrypt don't return bad hashes. # bug had 15/16 chance of occurring every time salt generated. # so we call it a few different way a number of times. - for i in xrange(6): + for i in irange(6): check_padding(bcrypt.genconfig()) - for i in xrange(3): + for i in irange(3): check_padding(bcrypt.encrypt("bob", rounds=bcrypt.min_rounds)) # check passing salt to genconfig causes it to be normalized. @@ -211,11 +212,11 @@ class _BCryptTest(HandlerCase): self.assertEqual(bcrypt.genhash(PASS2, GOOD2), GOOD2) self.assertFalse(wlog) - + self.assertEqual(bcrypt.genhash(PASS3, BAD3), GOOD3) check_warning(wlog) self.assertFalse(wlog) - + # make sure verify works on both bad and good hashes with catch_warnings(record=True) as wlog: warnings.simplefilter("always") diff --git a/passlib/tests/test_utils.py b/passlib/tests/test_utils.py index b5fe81a..753ee69 100644 --- a/passlib/tests/test_utils.py +++ b/passlib/tests/test_utils.py @@ -205,7 +205,7 @@ class MiscTest(TestCase): ##incorrect = u"abcdxfgh" ##print ##first = True - ##for run in xrange(1): + ##for run in irange(1): ## times = [] ## chars = [] ## for m in multipliers: diff --git a/passlib/tests/utils.py b/passlib/tests/utils.py index 42706d3..a484b1a 100644 --- a/passlib/tests/utils.py +++ b/passlib/tests/utils.py @@ -37,7 +37,7 @@ from passlib import registry, utils from passlib.utils import classproperty, handlers as uh, \ has_rounds_info, has_salt_info, MissingBackendError, \ rounds_cost_values, b, bytes, native_str, NoneType -from passlib.utils.compat import iteritems +from passlib.utils.compat import iteritems, irange #local __all__ = [ #util funcs @@ -856,7 +856,7 @@ class HandlerCase(TestCase): #make sure all listed chars are accepted chunk = 32 if mx is None else mx - for i in xrange(0,len(cs),chunk): + for i in irange(0,len(cs),chunk): salt = cs[i:i+chunk] if len(salt) < mn: salt = (salt*(mn//len(salt)+1))[:chunk] |
