import sys
import unittest
+import entry
import fdt
import fdt_util
import tools
-entry = None
-
class TestEntry(unittest.TestCase):
def setUp(self):
tools.PrepareOutputDir(None)
dtb = fdt.FdtScan(fname)
return dtb.GetNode('/binman/u-boot')
- def test1EntryNoImportLib(self):
- """Test that we can import Entry subclassess successfully"""
-
- sys.modules['importlib'] = None
- global entry
- import entry
- entry.Entry.Create(None, self.GetNode(), 'u-boot')
-
- def test2EntryImportLib(self):
- del sys.modules['importlib']
+ def _ReloadEntry(self):
global entry
if entry:
if sys.version_info[0] >= 3:
reload(entry)
else:
import entry
+
+ def test1EntryNoImportLib(self):
+ """Test that we can import Entry subclassess successfully"""
+ sys.modules['importlib'] = None
+ global entry
+ self._ReloadEntry()
+ entry.Entry.Create(None, self.GetNode(), 'u-boot')
+ self.assertFalse(entry.have_importlib)
+
+ def test2EntryImportLib(self):
+ del sys.modules['importlib']
+ global entry
+ self._ReloadEntry()
entry.Entry.Create(None, self.GetNode(), 'u-boot-spl')
- del entry
+ self.assertTrue(entry.have_importlib)
def testEntryContents(self):
"""Test the Entry bass class"""
def testUnknownEntry(self):
"""Test that unknown entry types are detected"""
- import entry
Node = collections.namedtuple('Node', ['name', 'path'])
node = Node('invalid-name', 'invalid-path')
with self.assertRaises(ValueError) as e:
def testUniqueName(self):
"""Test Entry.GetUniqueName"""
- import entry
Node = collections.namedtuple('Node', ['name', 'parent'])
base_node = Node('root', None)
base_entry = entry.Entry(None, None, base_node, read_node=False)
def testGetDefaultFilename(self):
"""Trivial test for this base class function"""
- import entry
base_entry = entry.Entry(None, None, None, read_node=False)
self.assertIsNone(base_entry.GetDefaultFilename())