~osomon/moovida/upicek_release_scripts

« back to all changes in this revision

Viewing changes to elisa-plugins/elisa/plugins/tutorials/amazon/tests/test_resource_provider.py

  • Committer: Olivier Tilloy
  • Date: 2008-10-06 11:21:47 UTC
  • mfrom: (771.1.2 upicek_hashlib)
  • Revision ID: olivier@fluendo.com-20081006112147-key4lrmtc0f95hd0
 Fallback to md5 when hashlib is not available (python < 2.5).

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
from elisa.plugins.tutorials.amazon.resource_provider import \
28
28
     AmazonResourceProvider, IMG_SERVER
29
29
 
30
 
import hashlib
 
30
try:
 
31
    from hashlib import md5
 
32
except ImportError:
 
33
    # hashlib is new in Python 2.5
 
34
    from md5 import md5
31
35
 
32
36
class TestAmazonResourceProvider(TestCase):
33
37
 
61
65
        # Callback triggered when a response to the request is received
62
66
        def request_done(model):
63
67
            self.failUnless(hasattr(model, 'data'))
64
 
            md5 = hashlib.md5(model.data).hexdigest()
 
68
            md5 = md5(model.data).hexdigest()
65
69
            self.failUnlessEqual(md5, expected_md5)
66
70
 
67
71
        # GET request