Changeset 39
- Timestamp:
- 06/03/06 15:05:29 (6 years ago)
- Files:
-
- branches/mk/cheesecake/codeparser.py (modified) (1 diff)
- branches/mk/tests/data/module1.py (modified) (1 diff)
- branches/mk/tests/data/package2.tar.gz (added)
- branches/mk/tests/test_code_parser.py (modified) (2 diffs)
- branches/mk/tests/test_index_docstrings.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/mk/cheesecake/codeparser.py
r38 r39 9 9 """ 10 10 11 # Word in reST can also contain hyphens and punctuation characters.11 # Handy regular expressions. 12 12 mapping = {'ALPHA': r'[-.,?!\w]', 'WORD': r'[-.,?!\s\w]', 13 13 'START': r'(^|\s)', 'END': r'([.,?!\s]|$)'} branches/mk/tests/data/module1.py
r37 r39 99 99 class Class3(object): 100 100 """ 101 Class with epytext link: U{http://pycheesecake.org}.101 New-style class with epytext link: U{http://pycheesecake.org}. 102 102 """ 103 103 pass 104 104 105 106 def outer_function(*args): 107 x = 42 108 109 def inner_function(): 110 """Short docstring.""" 111 pass 112 113 return x branches/mk/tests/test_code_parser.py
r37 r39 43 43 "module1.func7", 44 44 "module1.func8", 45 "module1.outer_function", 46 "module1.outer_function.inner_function", 45 47 ] 46 48 47 49 def test_count(self): 48 assert self.code1.object_count() == 1949 assert self.code1.docstring_count() == 1 650 assert self.code1.object_count() == 21 51 assert self.code1.docstring_count() == 17 50 52 assert self.code1.docstring_count_by_type('reST') == 2 51 53 assert self.code1.docstring_count_by_type('epytext') == 3 … … 70 72 "module1.func7", 71 73 "module1.func8", 74 "module1.outer_function.inner_function", 72 75 ] 73 76 objects_with_rest_docstrings = [ branches/mk/tests/test_index_docstrings.py
r33 r39 9 9 class TestIndexDocstrings(object): 10 10 def setUp(self): 11 self.cheesecake = Cheesecake(path=os.path.join(datadir, "package1.tar.gz")) 12 self.code = CodeParser(os.path.join(self.cheesecake.sandbox, "package1/module1.py")) 13 self.index_float = float(self.code.docstring_count()) / float(self.code.object_count()) 11 self.cheesecake = Cheesecake(path=os.path.join(datadir, "package2.tar.gz")) 12 13 modules = 5 14 classes = 2 15 functions = 4 16 methods = 3 17 18 self.documentable_objects = modules + classes + functions + methods 19 self.docstring_count = 7 20 21 self.index_float = float(self.docstring_count) / self.documentable_objects 14 22 self.index_int = int(ceil(self.index_float*100)) 15 23 … … 19 27 def test_index_docstrings(self): 20 28 index = self.cheesecake.index_docstrings() 29 21 30 assert index.name == "index_docstrings" 22 31 assert index.value == self.index_int 23 32 assert index.details == "found %d/%d=%.2f%% modules/classes/methods/functions with docstrings" %\ 24 (self. code.docstring_count(), self.code.object_count(), self.index_float*100)33 (self.docstring_count, self.documentable_objects, self.index_float*100)
