~pythonregexp2.7/python/issue2636-09-01+10

« back to all changes in this revision

Viewing changes to Lib/test/test_hashlib.py

  • Committer: Jeffrey C. "The TimeHorse" Jacobs
  • Date: 2008-09-22 21:39:45 UTC
  • mfrom: (39055.1.33 Regexp-2.7)
  • Revision ID: darklord@timehorse.com-20080922213945-23717m5eiqpamcyn
Merged in changes from the Single-Loop Engine branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
import hashlib
10
10
import unittest
11
11
from test import test_support
12
 
 
 
12
from test.test_support import _4G, precisionbigmemtest
13
13
 
14
14
def hexstr(s):
15
15
    import string
55
55
            m2.update(aas + bees + cees)
56
56
            self.assertEqual(m1.digest(), m2.digest())
57
57
 
58
 
 
59
58
    def check(self, name, data, digest):
60
59
        # test the direct constructors
61
60
        computed = getattr(hashlib, name)(data).hexdigest()
75
74
        self.check('md5', 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789',
76
75
                   'd174ab98d277d9f5a5611c2c9f419d9f')
77
76
 
 
77
    @precisionbigmemtest(size=_4G + 5, memuse=1)
 
78
    def test_case_md5_huge(self, size):
 
79
        if size == _4G + 5:
 
80
            try:
 
81
                self.check('md5', 'A'*size, 'c9af2dff37468ce5dfee8f2cfc0a9c6d')
 
82
            except OverflowError:
 
83
                pass # 32-bit arch
 
84
 
 
85
    @precisionbigmemtest(size=_4G - 1, memuse=1)
 
86
    def test_case_md5_uintmax(self, size):
 
87
        if size == _4G - 1:
 
88
            try:
 
89
                self.check('md5', 'A'*size, '28138d306ff1b8281f1a9067e1a1a2b3')
 
90
            except OverflowError:
 
91
                pass # 32-bit arch
78
92
 
79
93
    # use the three examples from Federal Information Processing Standards
80
94
    # Publication 180-1, Secure Hash Standard,  1995 April 17