Skip to content

Commit

Permalink
Merge pull request #404 from ogayot/libnvme-mock-test-version
Browse files Browse the repository at this point in the history
Attempt to fix the mock libnvme test so it works in GitHub actions & autopkgtest
  • Loading branch information
martin-belanger authored Nov 27, 2023
2 parents 795f7e6 + 2efebdb commit 30a02ba
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions test/test-defs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/python3
import contextlib
import os
import sys
import unittest
Expand All @@ -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
Expand Down

0 comments on commit 30a02ba

Please sign in to comment.