Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / tools / telemetry / third_party / modulegraph / modulegraph_tests / test_explicit_packages.py
bloba964e4f48c4c3d296efe4a7fa2568e3ee7c92021
1 from __future__ import absolute_import
2 import unittest
4 import os, shutil, sys
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):
17 root = os.path.join(
18 os.path.dirname(os.path.abspath(__file__)),
19 'testpkg-packages')
21 mf = find_modules.find_modules(
22 path=[root]+sys.path,
23 scripts=[os.path.join(root, "main_script.py")],
24 packages=['pkg'],
25 debug=1)
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):
34 root = os.path.join(
35 os.path.dirname(os.path.abspath(__file__)),
36 'testpkg-packages')
38 mf = find_modules.find_modules(
39 path=[root]+sys.path,
40 scripts=[os.path.join(root, "main_script.py")],
41 packages=['pkg'],
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__':
51 unittest.main()