OLD | NEW |
| (Empty) |
1 from __future__ import absolute_import | |
2 import unittest | |
3 | |
4 import os, shutil, sys | |
5 | |
6 from modulegraph import find_modules | |
7 from modulegraph import modulegraph | |
8 | |
9 | |
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)) | |
15 | |
16 def testIncludePackage(self): | |
17 root = os.path.join( | |
18 os.path.dirname(os.path.abspath(__file__)), | |
19 'testpkg-packages') | |
20 | |
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) | |
26 | |
27 node = mf.findNode('pkg') | |
28 self.assertIsInstance(node, modulegraph.Package) | |
29 | |
30 node = mf.findNode('pkg.sub3') | |
31 self.assertIsInstance(node, modulegraph.SourceModule) | |
32 | |
33 def testIncludePackageWithExclude(self): | |
34 root = os.path.join( | |
35 os.path.dirname(os.path.abspath(__file__)), | |
36 'testpkg-packages') | |
37 | |
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']) | |
43 | |
44 node = mf.findNode('pkg') | |
45 self.assertIsInstance(node, modulegraph.Package) | |
46 | |
47 node = mf.findNode('pkg.sub3') | |
48 self.assertIsInstance(node, modulegraph.ExcludedModule) | |
49 | |
50 if __name__ == '__main__': | |
51 unittest.main() | |
OLD | NEW |