root/tests/test_index_docstrings.py

Revision 2, 1.0 kB (checked in by grig, 5 years ago)

Initial import

Line 
1 import _path_cheesecake
2 from cheesecake.cheesecake_index import Cheesecake, CodeParser
3 import os
4 from math import ceil
5 datadir = os.path.abspath(os.path.join(os.path.dirname(__file__), "data"))
6
7 class TestIndexDocstrings:
8     def setUp(self):
9         self.cheesecake = Cheesecake(path=os.path.join(datadir, "package1.tar.gz"))
10         self.code = CodeParser(os.path.join(self.cheesecake.sandbox, "package1/module1.py"))
11         self.index_float = float(self.code.docstring_count()) / float(self.code.object_count())
12         self.index_int = int(ceil(self.index_float*100))
13
14     def tearDown(self):
15         self.cheesecake.cleanup()
16
17     def test_index_docstrings(self):
18         index = self.cheesecake.index_docstrings()
19         assert index.name == "index_docstrings"
20         assert index.value == self.index_int
21         assert index.details == "found %d/%d=%.2f%% modules/classes/methods/functions with docstrings" %\
22                             (self.code.docstring_count(), self.code.object_count(), self.index_float*100)
Note: See TracBrowser for help on using the browser.