Permalink
Browse files

Added test for missing docstrings in bindings.

  • Loading branch information...
MichaelClerx committed Aug 14, 2018
1 parent 4a6788a commit 2c306e122e847569b9dd51eb30a734dbe3f55392
Showing with 33 additions and 0 deletions.
  1. +1 −0 tests/bindings/python/CMakeLists.txt
  2. +32 −0 tests/bindings/python/test_docstrings.py
@@ -18,6 +18,7 @@ set(TEST_SRCS
test_validator.py
test_version.py
test_when.py
test_docstrings.py
)
foreach(_TEST ${TEST_SRCS})
@@ -0,0 +1,32 @@
#
# Tests if all CellML bindings have docstrings set.
#
import unittest
import types
class DocstringTestCase(unittest.TestCase):
def test_docstrings(self):
import libcellml
# Scan for missing or empty docstrings
def scan(root, missing, prefix=''):
prefix += root.__name__
if not root.__doc__:
missing.append(prefix)
prefix += '.'
for x in dir(root):
if x[:1] != '_' and x is not root:
child = getattr(root, x)
if isinstance(child, (type, types.FunctionType)):
scan(child, missing, prefix)
missing = []
scan(libcellml, missing)
if missing:
raise Exception('Missing docstrings for: ' + ', '.join(missing))
if __name__ == '__main__':
unittest.main()

0 comments on commit 2c306e1

Please sign in to comment.