1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 from os import F_OK, access, listdir, sep
24 from os.path import isdir
25 from re import search
26
27
28 from status import Status; status = Status()
29 from test_suite.unit_tests.base_classes import UnitTestCase
30
31
33 """Base class for the unit tests of the relax packages."""
34
36 """Check if all modules are located within the __all__ list."""
37
38
39 print("The %s.__all__ list: %s" % (self.package_name, self.package.__all__))
40
41
42 print("\nChecking for modules/packages missing from the __all__ list.")
43 files = listdir(self.package_path)
44 skip = ['__init__.py']
45 for file in files:
46
47 path = status.install_path + sep + self.package_name + sep + file
48
49
50 if file in skip:
51 continue
52
53
54 if search("^\.", file):
55 continue
56
57
58 if file == '__pycache__':
59 continue
60
61
62 if not search("\.py$", file) and not isdir(path):
63 continue
64
65
66 if hasattr(self, 'blacklist') and file in self.blacklist:
67 continue
68
69
70 module = file
71 if search('.py$', module):
72 module = module[:-3]
73 if search('.so$', module):
74 module = module[:-3]
75 if search('.pyd$', module):
76 module = module[:-4]
77
78
79 print(" Module/package: %s" % module)
80
81
82 self.assert_(module in self.package.__all__)
83
84
85 print("\nChecking for modules/packages in the __all__ list which do not exist.")
86 for module in self.package.__all__:
87
88 print(" Module/package: %s" % module)
89
90
91 if access(self.package_path+sep+module+'.py', F_OK):
92 continue
93
94
95 if access(self.package_path+sep+module+'.so', F_OK):
96 continue
97 if access(self.package_path+sep+module+'.pyd', F_OK):
98 continue
99
100
101 if access(self.package_path+sep+module, F_OK):
102 continue
103
104
105 self.fail()
106