diff options
author | Jim Carroll <jim@caroll.com> | 2016-07-28 15:19:25 -0400 |
---|---|---|
committer | Matěj Cepl <mcepl@cepl.eu> | 2017-09-15 14:42:52 +0200 |
commit | db146588d60fda5d490395779c525e1f06d66151 (patch) | |
tree | fc95ba606daded933863c6038564f7afaa8682ba /tests/test_rand.py | |
parent | 5a46756788ebe8a814520e8af3c56016f472d474 (diff) | |
download | m2crypto-db146588d60fda5d490395779c525e1f06d66151.tar.gz |
Corrected search for Rand.rand_file_name() on windows
Diffstat (limited to 'tests/test_rand.py')
-rw-r--r-- | tests/test_rand.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/tests/test_rand.py b/tests/test_rand.py index 78e4c26..b09c009 100644 --- a/tests/test_rand.py +++ b/tests/test_rand.py @@ -32,12 +32,14 @@ class RandTestCase(unittest.TestCase): self.assertEqual(b, 1) def test_file_name(self): - if "RANDFILE" in os.environ: - self.assertEqual(Rand.rand_file_name(), - os.environ["RANDFILE"]) + if os.name == 'nt': + rand_env = ('RANDFILE', 'HOME', 'USERPROFILE', 'SYSTEMROOT') else: - self.assertEqual(Rand.rand_file_name(), - os.path.join(os.environ["HOME"], ".rnd")) + rand_env = ('RANDFILE', 'HOME') + key = next((k for k in rand_env if os.environ.get(k)), None) + self.assertIsNotNone(key, "Could not find required environment") + rand_file = os.path.abspath(os.path.join(os.environ[key], '.rnd')) + self.assertEqual(os.path.abspath(Rand.rand_file_name()), rand_file) def test_load_save(self): try: |