From d81e0038d2d1729dde50fbb0e90b39089f485b19 Mon Sep 17 00:00:00 2001 From: Robey Pointer Date: Sun, 17 Feb 2008 18:41:39 -0800 Subject: [PATCH] [project @ robey@lag.net-20080218024139-i2t8y0f0dd93xjo1] bug 189466: fix typo in osrandom.py (from patch in bug report) and add a friggin' unit test. --- paramiko/osrandom.py | 2 +- tests/test_util.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/paramiko/osrandom.py b/paramiko/osrandom.py index 47c8f44..ca2a0bc 100644 --- a/paramiko/osrandom.py +++ b/paramiko/osrandom.py @@ -44,7 +44,7 @@ if osrandom_source is None: try: _dev_urandom = open("/dev/urandom", "rb", 0) def urandom(bytes): - return _def_urandom.read(bytes) + return _dev_urandom.read(bytes) osrandom_source = "/dev/urandom" except (OSError, IOError): pass diff --git a/tests/test_util.py b/tests/test_util.py index 2cf5782..05fcc67 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -142,3 +142,9 @@ class UtilTest (unittest.TestCase): finally: os.unlink('hostfile.temp') + def test_6_random(self): + from paramiko.common import randpool + # just verify that we can pull out 32 bytes and not get an exception. + x = randpool.get_bytes(32) + self.assertEquals(len(x), 32) +