Commit 4b373c42 authored by Alex Willmer's avatar Alex Willmer Committed by David Wilson

core: Standardise type of Importer.whitelist

This seemed a reasonable streamlining, but I'm happy to be overruled.
parent ecaa8609
......@@ -420,7 +420,7 @@ class Importer(object):
'utils',
]}
self._lock = threading.Lock()
self.whitelist = whitelist or ['']
self.whitelist = list(whitelist) or ['']
self.blacklist = list(blacklist) + [
# 2.x generates needless imports for 'builtins', while 3.x does the
# same for '__builtin__'. The correct one is built-in, the other
......
......@@ -32,6 +32,8 @@ class ImporterBlacklist(testlib.TestCase):
importer = mitogen.core.Importer(
router=mock.Mock(), context=None, core_src='',
)
self.assertIsInstance(importer.whitelist, list)
self.assertIsInstance(importer.blacklist, list)
self.assertFalse(mitogen.core.is_blacklisted_import(importer, 'mypkg'))
self.assertFalse(mitogen.core.is_blacklisted_import(importer, 'mypkg.mod'))
self.assertFalse(mitogen.core.is_blacklisted_import(importer, 'otherpkg'))
......@@ -44,6 +46,8 @@ class ImporterBlacklist(testlib.TestCase):
router=mock.Mock(), context=None, core_src='',
whitelist=('mypkg',),
)
self.assertIsInstance(importer.whitelist, list)
self.assertIsInstance(importer.blacklist, list)
self.assertFalse(mitogen.core.is_blacklisted_import(importer, 'mypkg'))
self.assertFalse(mitogen.core.is_blacklisted_import(importer, 'mypkg.mod'))
self.assertTrue(mitogen.core.is_blacklisted_import(importer, 'otherpkg'))
......@@ -56,6 +60,8 @@ class ImporterBlacklist(testlib.TestCase):
router=mock.Mock(), context=None, core_src='',
blacklist=('mypkg',),
)
self.assertIsInstance(importer.whitelist, list)
self.assertIsInstance(importer.blacklist, list)
self.assertTrue(mitogen.core.is_blacklisted_import(importer, 'mypkg'))
self.assertTrue(mitogen.core.is_blacklisted_import(importer, 'mypkg.mod'))
self.assertFalse(mitogen.core.is_blacklisted_import(importer, 'otherpkg'))
......@@ -68,6 +74,8 @@ class ImporterBlacklist(testlib.TestCase):
router=mock.Mock(), context=None, core_src='',
whitelist=('mypkg',), blacklist=('mypkg',),
)
self.assertIsInstance(importer.whitelist, list)
self.assertIsInstance(importer.blacklist, list)
self.assertTrue(mitogen.core.is_blacklisted_import(importer, 'mypkg'))
self.assertTrue(mitogen.core.is_blacklisted_import(importer, 'mypkg.mod'))
self.assertTrue(mitogen.core.is_blacklisted_import(importer, 'otherpkg'))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment