You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
import inspect
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
import testlib
|
|
|
|
import mitogen.master
|
|
|
|
|
|
|
|
|
|
|
|
class ScanCodeImportsTest(testlib.TestCase):
|
|
|
|
func = staticmethod(mitogen.master.scan_code_imports)
|
|
|
|
|
|
|
|
if mitogen.core.PY3:
|
|
|
|
level = 0
|
|
|
|
else:
|
|
|
|
level = -1
|
|
|
|
|
|
|
|
SIMPLE_EXPECT = [
|
|
|
|
(level, 'inspect', ()),
|
|
|
|
(level, 'unittest', ()),
|
|
|
|
(level, 'testlib', ()),
|
|
|
|
(level, 'mitogen.master', ()),
|
|
|
|
]
|
|
|
|
|
|
|
|
def test_simple(self):
|
|
|
|
source_path = inspect.getsourcefile(ScanCodeImportsTest)
|
|
|
|
with open(source_path) as f:
|
|
|
|
co = compile(f.read(), source_path, 'exec')
|
|
|
|
self.assertEqual(list(self.func(co)), self.SIMPLE_EXPECT)
|