summaryrefslogtreecommitdiffstats
path: root/test/test_rand.py
blob: 76b4d241a36593328ac79d20111999935907840b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import sys
import unittest

import rand


class RandTestCase(unittest.TestCase):
    def test_rand_status(self):
        self.assertEqual(rand.rand_status(), 1)

    def test_rand_event(self):
        if sys.platform == 'win32':
            self.assertIsNotNone(rand.rand_event(1, 1, 1))
        else:
            self.assertIsNone(rand.rand_event(1, 1, 1))

    def test_rand_bytes(self):
        exp_length = 15
        r = rand.rand_bytes(exp_length)
        self.assertIsInstance(r, bytes)
        self.assertEqual(len(r), exp_length)

    def test_rand_pseudo_bytes(self):
        exp_length = 15
        r = rand.rand_pseudo_bytes(exp_length)
        self.assertIsInstance(r[0], bytes)
        self.assertEqual(len(r[0]), exp_length)
        self.assertEqual(r[1], 1)

if __name__ == '__main__':
    unittest.main()