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 files.sort()
45 skip = ['__init__.py']
46 for file in files:
47
48 path = status.install_path + sep + self.package_name + sep + file
49
50
51 if file in skip:
52 continue
53
54
55 if search(r"^\.", file):
56 continue
57
58
59 if file == '__pycache__':
60 continue
61
62
63 if not search(r"\.py$", file) and not isdir(path):
64 continue
65
66
67 if hasattr(self, 'blacklist') and file in self.blacklist:
68 continue
69
70
71 module = file
72 if search('.py$', module):
73 module = module[:-3]
74 if search('.so$', module):
75 module = module[:-3]
76 if search('.pyd$', module):
77 module = module[:-4]
78
79
80 print(" Module/package: %s" % module)
81
82
83 self.assertTrue(module in self.package.__all__)
84
85
86 print("\nChecking for modules/packages in the __all__ list which do not exist.")
87 for module in self.package.__all__:
88
89 print(" Module/package: %s" % module)
90
91
92 if access(self.package_path+sep+module+'.py', F_OK):
93 continue
94
95
96 if access(self.package_path+sep+module+'.so', F_OK):
97 continue
98 if access(self.package_path+sep+module+'.pyd', F_OK):
99 continue
100
101
102 if access(self.package_path+sep+module, F_OK):
103 continue
104
105
106 if hasattr(self, 'blacklist') and (module+'.py' in self.blacklist or module+'.so' in self.blacklist):
107 continue
108
109
110 self.fail()
111