summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2017-11-12 21:52:20 -0700
committerSimon Glass <sjg@chromium.org>2017-11-22 18:05:38 -0700
commit4d5994f91c5c781fb0c8b32b58abfc4d9d2ec878 (patch)
tree6c37ad79e68d7e2a4971dd04304370bd0079eeac /tools
parent5a3f2226043cd46d446ab6eba39e47d131b47175 (diff)
binman: Set up 'entry' to permit full test coverage
There is a little check at the top of entry.py which decides if importlib is available. At present this has no test coverage. To add this we will need to import the module twice, once with importlib and once without. In preparation for allowing a test to control the importing of this module, remove all global imports of the 'entry' module. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/binman/entry_test.py4
-rw-r--r--tools/binman/ftest.py4
-rw-r--r--tools/binman/image.py7
3 files changed, 10 insertions, 5 deletions
diff --git a/tools/binman/entry_test.py b/tools/binman/entry_test.py
index 8a9ae017f0..85c4196892 100644
--- a/tools/binman/entry_test.py
+++ b/tools/binman/entry_test.py
@@ -9,16 +9,16 @@
import collections
import unittest
-import entry
-
class TestEntry(unittest.TestCase):
def testEntryContents(self):
"""Test the Entry bass class"""
+ import entry
base_entry = entry.Entry(None, None, None, read_node=False)
self.assertEqual(True, base_entry.ObtainContents())
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:
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index c4207ce5d2..eae1ab1c4b 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -20,7 +20,6 @@ import binman
import cmdline
import command
import control
-import entry
import fdt
import fdt_util
import tools
@@ -56,6 +55,9 @@ class TestFunctional(unittest.TestCase):
"""
@classmethod
def setUpClass(self):
+ global entry
+ import entry
+
# Handle the case where argv[0] is 'python'
self._binman_dir = os.path.dirname(os.path.realpath(sys.argv[0]))
self._binman_pathname = os.path.join(self._binman_dir, 'binman')
diff --git a/tools/binman/image.py b/tools/binman/image.py
index 07fc930665..24c4f6f578 100644
--- a/tools/binman/image.py
+++ b/tools/binman/image.py
@@ -9,8 +9,6 @@
from collections import OrderedDict
from operator import attrgetter
-import entry
-from entry import Entry
import fdt_util
import tools
@@ -48,6 +46,11 @@ class Image:
_entries: OrderedDict() of entries
"""
def __init__(self, name, node):
+ global entry
+ global Entry
+ import entry
+ from entry import Entry
+
self._node = node
self._name = name
self._size = None