Package test_suite :: Package unit_tests :: Module package_checking
[hide private]
[frames] | no frames]

Source Code for Module test_suite.unit_tests.package_checking

 1  ############################################################################### 
 2  #                                                                             # 
 3  # Copyright (C) 2009-2012 Edward d'Auvergne                                   # 
 4  #                                                                             # 
 5  # This file is part of the program relax (http://www.nmr-relax.com).          # 
 6  #                                                                             # 
 7  # This program is free software: you can redistribute it and/or modify        # 
 8  # it under the terms of the GNU General Public License as published by        # 
 9  # the Free Software Foundation, either version 3 of the License, or           # 
10  # (at your option) any later version.                                         # 
11  #                                                                             # 
12  # This program is distributed in the hope that it will be useful,             # 
13  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
15  # GNU General Public License for more details.                                # 
16  #                                                                             # 
17  # You should have received a copy of the GNU General Public License           # 
18  # along with this program.  If not, see <http://www.gnu.org/licenses/>.       # 
19  #                                                                             # 
20  ############################################################################### 
21   
22  # Python module imports. 
23  from os import F_OK, access, listdir, sep 
24  from re import search 
25   
26  # relax module imports. 
27  from test_suite.unit_tests.base_classes import UnitTestCase 
28   
29   
30 -class PackageTestCase(UnitTestCase):
31 """Base class for the unit tests of the relax packages.""" 32
33 - def test___all__(self):
34 """Check if all modules are located within the __all__ list.""" 35 36 print("The %s.__all__ list: %s" % (self.package_name, self.package.__all__)) 37 38 # Loop over all files. 39 files = listdir(self.package_path) 40 for file in files: 41 # Only look at the '*.py' files. 42 if not search('.py$', file): 43 continue 44 45 # Skip the __init__.py file. 46 if file == '__init__.py': 47 continue 48 49 # Skip blacklisted files. 50 if hasattr(self, 'blacklist') and file in self.blacklist: 51 continue 52 53 # Remove the '.py' part. 54 module = file[:-3] 55 56 # Print out. 57 print("\nFile: %s" % file) 58 print("Checking module: %s" % module) 59 60 # Check if the module is in __all__. 61 self.assert_(module in self.package.__all__) 62 63 # Loop over all modules. 64 for module in self.package.__all__: 65 # The file name. 66 file = module + '.py' 67 68 # Print out. 69 print("\nModule: %s" % module) 70 print("Checking file: %s" % file) 71 72 # Check for the file. 73 if access(self.package_path + sep + file, F_OK): 74 continue 75 76 # Check for the package. 77 if access(self.package_path + sep + module, F_OK): 78 continue 79 80 # Doesn't exist, so fail. 81 self.fail()
82