diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-12-10 10:25:04 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-12-10 10:25:04 +0000 |
commit | 8622cbe476ee19b12d6d4ea77250146d5cb8717f (patch) | |
tree | 06a46583880489d4fba8f2f5c4450a23c33f58cc /test/test-defs.py | |
parent | Adding upstream version 2.3. (diff) | |
download | nvme-stas-upstream.tar.xz nvme-stas-upstream.zip |
Adding upstream version 2.3.1.upstream/2.3.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/test-defs.py')
-rwxr-xr-x | test/test-defs.py | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/test/test-defs.py b/test/test-defs.py index 3f8b02b..9098ef0 100755 --- a/test/test-defs.py +++ b/test/test-defs.py @@ -1,4 +1,5 @@ #!/usr/bin/python3 +import contextlib import os import sys import unittest @@ -9,13 +10,17 @@ class MockLibnvmeTestCase(unittest.TestCase): '''Testing defs.py by mocking the libnvme package''' def test_libnvme_version(self): - # For unknown reasons, this test does - # not work when run from GitHub Actions. - if not os.getenv('GITHUB_ACTIONS'): - from staslib import defs + # Ensure that we re-import staslib & staslib.defs if the current Python + # process has them already imported. + with contextlib.suppress(KeyError): + sys.modules.pop('staslib.defs') + with contextlib.suppress(KeyError): + sys.modules.pop('staslib') - libnvme_ver = defs.LIBNVME_VERSION - self.assertEqual(libnvme_ver, '?.?') + from staslib import defs + + libnvme_ver = defs.LIBNVME_VERSION + self.assertEqual(libnvme_ver, '?.?') @classmethod def setUpClass(cls): # called once before all the tests |