Changeset 89
- Timestamp:
- 07/19/06 09:36:58 (2 years ago)
- Files:
-
- branches/mk/cheesecake/cheesecake_index.py (modified) (5 diffs)
- branches/mk/cheesecake/codeparser.py (modified) (4 diffs)
- branches/mk/tests/unit/test_index_unittests.py (modified) (1 diff)
- branches/mk/tests/unit/test_index_use_test_framework.py (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/mk/cheesecake/cheesecake_index.py
r87 r89 820 820 return self.value 821 821 822 class IndexUseTestFramework(Index): 823 """Check if a package uses any of known test frameworks. 824 825 Currently only checking for doctest. 826 """ 827 max_value = 30 828 829 def compute(self, doctests_count): 830 if doctests_count > 0: 831 self.value = self.max_value 832 self.details = "found doctests" 833 else: 834 self.value = 0 835 self.details = "doesn't use any of known test frameworks" 836 837 return self.value 838 822 839 class IndexPyLint(Index): 823 840 """Compute pylint index as average of positive pylint scores obtained for … … 903 920 IndexPyLint, 904 921 IndexUnitTests, 922 IndexUseTestFramework, 905 923 ] 906 924 … … 1304 1322 docformat_cnt : int 1305 1323 Number of formatted docstrings found in all package objects. 1324 doctests_count : int 1325 Number of docstrings that include doctests. 1306 1326 files_list : list 1307 1327 List of files package contains. … … 1322 1342 self.docstring_cnt = 0 1323 1343 self.docformat_cnt = 0 1344 self.doctests_count = 0 1324 1345 self.functions = [] 1325 1346 self.classes = [] … … 1336 1357 self.functions += code.functions 1337 1358 self.classes += code.classes 1359 self.doctests_count += code.doctests_count 1338 1360 1339 1361 # Log a bit of debugging info. branches/mk/cheesecake/codeparser.py
r83 r89 1 import doctest 1 2 import os 2 3 import re 3 4 4 5 from model import System, Module, Class, Function, parseFile, processModuleAst 6 7 8 # Python 2.3/2.4 compatibilty hacks. 9 if getattr(doctest, 'DocTestParser', False): 10 # Python 2.4 have DocTestParser class. 11 get_doctests = doctest.DocTestParser().get_examples 12 else: 13 # Python 2.3 have _extract_examples function. 14 get_doctests = doctest._extract_examples 5 15 6 16 … … 112 122 self.docstrings_by_format = {} 113 123 self.formatted_docstrings_count = 0 124 self.doctests_count = 0 114 125 115 126 # Initialize lists of format docstrings. … … 146 157 self.formatted_docstrings_count += 1 147 158 159 # Check if docstring include any doctests. 160 if get_doctests(obj.docstring): 161 self.doctests_count += 1 162 148 163 for method_or_func in self.method_func: 149 164 method_found = 0 … … 161 176 self.log("functions: " + ",".join(self.functions)) 162 177 self.log("docstrings: %s" % self.docstrings_by_format) 178 self.log("number of doctests: %d" % self.doctests_count) 163 179 164 180 def object_count(self): branches/mk/tests/unit/test_index_unittests.py
r83 r89 7 7 import _path_cheesecake 8 8 9 from _helper_cheesecake import Glutton10 9 from cheesecake.cheesecake_index import IndexUnitTests 11 10 from cheesecake import logger
