mirror of
https://xff.cz/git/u-boot/
synced 2025-09-02 09:12:08 +02:00
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>
This commit is contained in:
@@ -9,16 +9,16 @@
|
|||||||
import collections
|
import collections
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import entry
|
|
||||||
|
|
||||||
class TestEntry(unittest.TestCase):
|
class TestEntry(unittest.TestCase):
|
||||||
def testEntryContents(self):
|
def testEntryContents(self):
|
||||||
"""Test the Entry bass class"""
|
"""Test the Entry bass class"""
|
||||||
|
import entry
|
||||||
base_entry = entry.Entry(None, None, None, read_node=False)
|
base_entry = entry.Entry(None, None, None, read_node=False)
|
||||||
self.assertEqual(True, base_entry.ObtainContents())
|
self.assertEqual(True, base_entry.ObtainContents())
|
||||||
|
|
||||||
def testUnknownEntry(self):
|
def testUnknownEntry(self):
|
||||||
"""Test that unknown entry types are detected"""
|
"""Test that unknown entry types are detected"""
|
||||||
|
import entry
|
||||||
Node = collections.namedtuple('Node', ['name', 'path'])
|
Node = collections.namedtuple('Node', ['name', 'path'])
|
||||||
node = Node('invalid-name', 'invalid-path')
|
node = Node('invalid-name', 'invalid-path')
|
||||||
with self.assertRaises(ValueError) as e:
|
with self.assertRaises(ValueError) as e:
|
||||||
|
@@ -20,7 +20,6 @@ import binman
|
|||||||
import cmdline
|
import cmdline
|
||||||
import command
|
import command
|
||||||
import control
|
import control
|
||||||
import entry
|
|
||||||
import fdt
|
import fdt
|
||||||
import fdt_util
|
import fdt_util
|
||||||
import tools
|
import tools
|
||||||
@@ -56,6 +55,9 @@ class TestFunctional(unittest.TestCase):
|
|||||||
"""
|
"""
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(self):
|
def setUpClass(self):
|
||||||
|
global entry
|
||||||
|
import entry
|
||||||
|
|
||||||
# Handle the case where argv[0] is 'python'
|
# Handle the case where argv[0] is 'python'
|
||||||
self._binman_dir = os.path.dirname(os.path.realpath(sys.argv[0]))
|
self._binman_dir = os.path.dirname(os.path.realpath(sys.argv[0]))
|
||||||
self._binman_pathname = os.path.join(self._binman_dir, 'binman')
|
self._binman_pathname = os.path.join(self._binman_dir, 'binman')
|
||||||
|
@@ -9,8 +9,6 @@
|
|||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from operator import attrgetter
|
from operator import attrgetter
|
||||||
|
|
||||||
import entry
|
|
||||||
from entry import Entry
|
|
||||||
import fdt_util
|
import fdt_util
|
||||||
import tools
|
import tools
|
||||||
|
|
||||||
@@ -48,6 +46,11 @@ class Image:
|
|||||||
_entries: OrderedDict() of entries
|
_entries: OrderedDict() of entries
|
||||||
"""
|
"""
|
||||||
def __init__(self, name, node):
|
def __init__(self, name, node):
|
||||||
|
global entry
|
||||||
|
global Entry
|
||||||
|
import entry
|
||||||
|
from entry import Entry
|
||||||
|
|
||||||
self._node = node
|
self._node = node
|
||||||
self._name = name
|
self._name = name
|
||||||
self._size = None
|
self._size = None
|
||||||
|
Reference in New Issue
Block a user