Fix deprecation warnings in test_os.py

This commit is contained in:
Ezio Melotti 2010-08-03 06:49:14 +00:00
parent 192f6782c6
commit aad1541484
1 changed files with 10 additions and 8 deletions

View File

@ -500,14 +500,16 @@ class DevNullTests (unittest.TestCase):
class URandomTests (unittest.TestCase): class URandomTests (unittest.TestCase):
def test_urandom(self): def test_urandom(self):
try: try:
self.assertEqual(len(os.urandom(1)), 1) with test_support._check_py3k_warnings(
self.assertEqual(len(os.urandom(10)), 10) ('integer argument expected, got float', DeprecationWarning)):
self.assertEqual(len(os.urandom(100)), 100) self.assertEqual(len(os.urandom(1)), 1)
self.assertEqual(len(os.urandom(1000)), 1000) self.assertEqual(len(os.urandom(10)), 10)
# see http://bugs.python.org/issue3708 self.assertEqual(len(os.urandom(100)), 100)
self.assertEqual(len(os.urandom(0.9)), 0) self.assertEqual(len(os.urandom(1000)), 1000)
self.assertEqual(len(os.urandom(1.1)), 1) # see http://bugs.python.org/issue3708
self.assertEqual(len(os.urandom(2.0)), 2) self.assertEqual(len(os.urandom(0.9)), 0)
self.assertEqual(len(os.urandom(1.1)), 1)
self.assertEqual(len(os.urandom(2.0)), 2)
except NotImplementedError: except NotImplementedError:
pass pass