Tres Seaver
2012-03-18 ac426723f8a0a9322dbc866d0d35b28326384b2a
Portable itertools {i,}zip_longest behavior.

More compat imports centralization.
2 files modified
19 ■■■■■ changed files
repoze/who/plugins/htpasswd.py 5 ●●●● patch | view | raw | blame | history
repoze/who/plugins/tests/test_htpasswd.py 14 ●●●● patch | view | raw | blame | history
repoze/who/plugins/htpasswd.py
@@ -4,6 +4,7 @@
from repoze.who.interfaces import IAuthenticator
from repoze.who.utils import resolveDotted
from repoze.who._compat import izip_longest
def _padding_for_file_lines():
@@ -80,7 +81,9 @@
def _same_string(x, y):
    # Attempt at isochronous string comparison.
    mismatches = filter(None, [a != b for a, b, ignored
                                    in itertools.izip_longest(x, y, PADDING)])
                                    in izip_longest(x, y, PADDING)])
    if type(mismatches) != list:
        mismatches = list(mismatches)
    return len(mismatches) == 0
def crypt_check(password, hashed):
repoze/who/plugins/tests/test_htpasswd.py
@@ -24,16 +24,16 @@
        verifyClass(IAuthenticator, klass)
    def test_authenticate_nocreds(self):
        from StringIO import StringIO
        from repoze.who._compat import StringIO
        io = StringIO()
        plugin = self._makeOne(io, None)
        environ = self._makeEnviron()
        creds = {}
        result = plugin.authenticate(environ, creds)
        self.assertEqual(result, None)
    def test_authenticate_nolines(self):
        from StringIO import StringIO
        from repoze.who._compat import StringIO
        io = StringIO()
        def check(password, hashed):
            return True
@@ -42,9 +42,9 @@
        creds = {'login':'chrism', 'password':'pass'}
        result = plugin.authenticate(environ, creds)
        self.assertEqual(result, None)
    def test_authenticate_nousermatch(self):
        from StringIO import StringIO
        from repoze.who._compat import StringIO
        io = StringIO('nobody:foo')
        def check(password, hashed):
            return True
@@ -55,7 +55,7 @@
        self.assertEqual(result, None)
    def test_authenticate_match(self):
        from StringIO import StringIO
        from repoze.who._compat import StringIO
        io = StringIO('chrism:pass')
        def check(password, hashed):
            return True
@@ -66,7 +66,7 @@
        self.assertEqual(result, 'chrism')
    def test_authenticate_badline(self):
        from StringIO import StringIO
        from repoze.who._compat import StringIO
        io = StringIO('badline\nchrism:pass')
        def check(password, hashed):
            return True