1 from __future__
import absolute_import
6 from modulegraph
import find_modules
7 from modulegraph
import modulegraph
10 class PackagesTestCase (unittest
.TestCase
):
11 if not hasattr(unittest
.TestCase
, 'assertIsInstance'):
12 def assertIsInstance(self
, object, types
, message
=None):
13 self
.assertTrue(isinstance(object, types
),
14 message
or '%r is not an instance of %r'%(object, types
))
16 def testIncludePackage(self
):
18 os
.path
.dirname(os
.path
.abspath(__file__
)),
21 mf
= find_modules
.find_modules(
23 scripts
=[os
.path
.join(root
, "main_script.py")],
27 node
= mf
.findNode('pkg')
28 self
.assertIsInstance(node
, modulegraph
.Package
)
30 node
= mf
.findNode('pkg.sub3')
31 self
.assertIsInstance(node
, modulegraph
.SourceModule
)
33 def testIncludePackageWithExclude(self
):
35 os
.path
.dirname(os
.path
.abspath(__file__
)),
38 mf
= find_modules
.find_modules(
40 scripts
=[os
.path
.join(root
, "main_script.py")],
42 excludes
=['pkg.sub3'])
44 node
= mf
.findNode('pkg')
45 self
.assertIsInstance(node
, modulegraph
.Package
)
47 node
= mf
.findNode('pkg.sub3')
48 self
.assertIsInstance(node
, modulegraph
.ExcludedModule
)
50 if __name__
== '__main__':