From c1c43cad63a88eae694b174c9a0fe6242dd5972b Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Sun, 5 Sep 2004 00:00:42 +0000 Subject: Fulfill Martin's request to use try/except rather than a "look before you leap" approach. Makes the early call to os.urandom() unnecessary. --- Lib/test/test_random.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'Lib/test/test_random.py') diff --git a/Lib/test/test_random.py b/Lib/test/test_random.py index 139e8bf294..f30ed1fbd4 100644 --- a/Lib/test/test_random.py +++ b/Lib/test/test_random.py @@ -495,7 +495,11 @@ def test_main(verbose=None): TestDistributions, TestModule] - if random._urandom is not None: + try: + random.HardwareRandom().random() + except NotImplementedError: + pass + else: testclasses.append(HardwareRandom_TestBasicOps) test_support.run_unittest(*testclasses) -- cgit v1.2.1