2018-04-01 00:21:42 +00:00
|
|
|
import inspect
|
2017-09-21 09:56:56 +00:00
|
|
|
|
2017-11-12 12:42:27 +00:00
|
|
|
import unittest2
|
2017-09-21 09:56:56 +00:00
|
|
|
|
|
|
|
import testlib
|
|
|
|
import mitogen.master
|
|
|
|
|
|
|
|
|
2017-11-12 12:42:27 +00:00
|
|
|
class ScanCodeImportsTest(unittest2.TestCase):
|
2017-09-30 08:25:41 +00:00
|
|
|
func = staticmethod(mitogen.master.scan_code_imports)
|
|
|
|
|
2018-06-26 02:56:45 +00:00
|
|
|
if mitogen.core.PY3:
|
|
|
|
level = 0
|
|
|
|
else:
|
|
|
|
level = -1
|
|
|
|
|
|
|
|
SIMPLE_EXPECT = [
|
|
|
|
(level, 'inspect', ()),
|
|
|
|
(level, 'unittest2', ()),
|
|
|
|
(level, 'testlib', ()),
|
|
|
|
(level, 'mitogen.master', ()),
|
|
|
|
]
|
|
|
|
|
2017-09-30 08:25:41 +00:00
|
|
|
def test_simple(self):
|
2018-04-01 00:21:42 +00:00
|
|
|
source_path = inspect.getsourcefile(ScanCodeImportsTest)
|
|
|
|
co = compile(open(source_path).read(), source_path, 'exec')
|
2018-06-26 02:56:45 +00:00
|
|
|
self.assertEquals(list(self.func(co)), self.SIMPLE_EXPECT)
|
2017-09-30 08:25:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2017-11-12 12:42:27 +00:00
|
|
|
unittest2.main()
|