Author: jezdez
Date: 2011-12-25 04:47:13 -0800 (Sun, 25 Dec 2011)
New Revision: 17273

Modified:
   django/trunk/django/utils/archive.py
   django/trunk/tests/regressiontests/utils/crypto.py
Log:
Fixed a few tests to run on Python 2.5. Thanks, Florian Apolloner.

Modified: django/trunk/django/utils/archive.py
===================================================================
--- django/trunk/django/utils/archive.py        2011-12-24 20:48:19 UTC (rev 
17272)
+++ django/trunk/django/utils/archive.py        2011-12-25 12:47:13 UTC (rev 
17273)
@@ -141,7 +141,7 @@
                 name = self.split_leading_dir(name)[1]
             filename = os.path.join(to_path, name)
             if member.isdir():
-                if not os.path.exists(filename):
+                if filename and not os.path.exists(filename):
                     os.makedirs(filename)
             else:
                 try:
@@ -153,7 +153,7 @@
                            (name, member.name, sys.exc_info()[1]))
                 else:
                     dirname = os.path.dirname(filename)
-                    if not os.path.exists(dirname):
+                    if dirname and not os.path.exists(dirname):
                         os.makedirs(dirname)
                     with open(filename, 'wb') as outfile:
                         shutil.copyfileobj(extracted, outfile)

Modified: django/trunk/tests/regressiontests/utils/crypto.py
===================================================================
--- django/trunk/tests/regressiontests/utils/crypto.py  2011-12-24 20:48:19 UTC 
(rev 17272)
+++ django/trunk/tests/regressiontests/utils/crypto.py  2011-12-25 12:47:13 UTC 
(rev 17273)
@@ -126,8 +126,8 @@
         times as long as running with 1 iteration.
         """
         n1, n2 = 100, 10000
-        elapsed = lambda f: timeit.timeit(f, number=1)
-        t1 = elapsed(lambda: pbkdf2("password", "salt", iterations=n1))
-        t2 = elapsed(lambda: pbkdf2("password", "salt", iterations=n2))
+        elapsed = lambda f: timeit.Timer(f, 'from django.utils.crypto import 
pbkdf2').timeit(number=1)
+        t1 = elapsed('pbkdf2("password", "salt", iterations=%d)' % n1)
+        t2 = elapsed('pbkdf2("password", "salt", iterations=%d)' % n2)
         measured_scale_exponent = math.log(t2 / t1, n2 / n1)
         self.assertLess(measured_scale_exponent, 1.1)

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to