Commit 9915b938 authored by Fred Drake's avatar Fred Drake

Use the random module instead of the deprecated whrandom module.

whrandom triggers a DeprecationWarning when using CVS Python.
parent d0724306
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
import sys, os, time, whrandom, unittest import sys, os, time, random, unittest
if __name__ == "__main__": if __name__ == "__main__":
sys.path.insert(0, '../../..') sys.path.insert(0, '../../..')
...@@ -165,7 +165,7 @@ class TestTransientObjectContainer(TestCase): ...@@ -165,7 +165,7 @@ class TestTransientObjectContainer(TestCase):
added = {} added = {}
r = range(10, 110) r = range(10, 110)
for x in r: for x in r:
k = whrandom.choice(r) k = random.choice(r)
if not added.has_key(k): if not added.has_key(k):
self.t[k] = x self.t[k] = x
added[k] = 1 added[k] = 1
...@@ -177,7 +177,7 @@ class TestTransientObjectContainer(TestCase): ...@@ -177,7 +177,7 @@ class TestTransientObjectContainer(TestCase):
added = {} added = {}
r = range(10, 110) r = range(10, 110)
for x in r: for x in r:
k = whrandom.choice(r) k = random.choice(r)
self.t[k] = x self.t[k] = x
added[k] = 1 added[k] = 1
addl = added.keys() addl = added.keys()
...@@ -188,12 +188,12 @@ class TestTransientObjectContainer(TestCase): ...@@ -188,12 +188,12 @@ class TestTransientObjectContainer(TestCase):
r = range(10, 1010) r = range(10, 1010)
added = [] added = []
for x in r: for x in r:
k = whrandom.choice(r) k = random.choice(r)
self.t[k] = x self.t[k] = x
added.append(k) added.append(k)
deleted = [] deleted = []
for x in r: for x in r:
k = whrandom.choice(r) k = random.choice(r)
if self.t.has_key(k): if self.t.has_key(k):
del self.t[k] del self.t[k]
deleted.append(k) deleted.append(k)
...@@ -208,7 +208,7 @@ class TestTransientObjectContainer(TestCase): ...@@ -208,7 +208,7 @@ class TestTransientObjectContainer(TestCase):
def testTargetedDeletes(self): def testTargetedDeletes(self):
r = range(10, 1010) r = range(10, 1010)
for x in r: for x in r:
k = whrandom.choice(r) k = random.choice(r)
self.t[k] = x self.t[k] = x
for x in r: for x in r:
try: try:
...@@ -372,7 +372,7 @@ class TestTransientObjectContainer(TestCase): ...@@ -372,7 +372,7 @@ class TestTransientObjectContainer(TestCase):
added = {} added = {}
r = range(10, 1010) r = range(10, 1010)
for x in r: for x in r:
k = whrandom.choice(r) k = random.choice(r)
self.t[k] = x self.t[k] = x
added[k] = x added[k] = x
addl = added.keys() addl = added.keys()
......
...@@ -11,9 +11,9 @@ ...@@ -11,9 +11,9 @@
# #
############################################################################## ##############################################################################
__version__='$Revision: 1.64 $'[11:-2] __version__='$Revision: 1.65 $'[11:-2]
import re, sys, os, urllib, time, whrandom, cgi, codecs import re, sys, os, urllib, time, random, cgi, codecs
from BaseRequest import BaseRequest from BaseRequest import BaseRequest
from HTTPResponse import HTTPResponse from HTTPResponse import HTTPResponse
from cgi import FieldStorage, escape from cgi import FieldStorage, escape
...@@ -114,7 +114,7 @@ class HTTPRequest(BaseRequest): ...@@ -114,7 +114,7 @@ class HTTPRequest(BaseRequest):
retry_max_count=3 retry_max_count=3
def supports_retry(self): def supports_retry(self):
if self.retry_count < self.retry_max_count: if self.retry_count < self.retry_max_count:
time.sleep(whrandom.uniform(0, 2**(self.retry_count))) time.sleep(random.uniform(0, 2**(self.retry_count)))
return 1 return 1
def retry(self): def retry(self):
......
"""HTTP 1.1 / WebDAV client library.""" """HTTP 1.1 / WebDAV client library."""
__version__='$Revision: 1.18 $'[11:-2] __version__='$Revision: 1.19 $'[11:-2]
import sys, os, time, types,re import sys, os, time, types,re
import socket, httplib, mimetools import socket, httplib, mimetools
...@@ -9,7 +9,7 @@ from mimetypes import guess_type ...@@ -9,7 +9,7 @@ from mimetypes import guess_type
from base64 import encodestring from base64 import encodestring
from common import rfc1123_date from common import rfc1123_date
from cStringIO import StringIO from cStringIO import StringIO
from whrandom import random from random import random
from urllib import quote from urllib import quote
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment