core: Standardise type of Importer.whitelist
This seemed a reasonable streamlining, but I'm happy to be overruled.
This commit is contained in:
parent
ecaa8609f3
commit
4b373c421b
|
@ -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'))
|
||||
|
|
Loading…
Reference in New Issue