|
Revision 33, 1.0 kB
(checked in by mk, 4 years ago)
|
Check docstrings for use of reST (closes ticket #11).
|
| Line | |
|---|
| 1 |
import os |
|---|
| 2 |
from math import ceil |
|---|
| 3 |
|
|---|
| 4 |
import _path_cheesecake |
|---|
| 5 |
from cheesecake.cheesecake_index import Cheesecake, CodeParser |
|---|
| 6 |
|
|---|
| 7 |
datadir = os.path.abspath(os.path.join(os.path.dirname(__file__), "data")) |
|---|
| 8 |
|
|---|
| 9 |
class TestIndexDocstrings(object): |
|---|
| 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()) |
|---|
| 14 |
self.index_int = int(ceil(self.index_float*100)) |
|---|
| 15 |
|
|---|
| 16 |
def tearDown(self): |
|---|
| 17 |
self.cheesecake.cleanup() |
|---|
| 18 |
|
|---|
| 19 |
def test_index_docstrings(self): |
|---|
| 20 |
index = self.cheesecake.index_docstrings() |
|---|
| 21 |
assert index.name == "index_docstrings" |
|---|
| 22 |
assert index.value == self.index_int |
|---|
| 23 |
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) |
|---|