salt/tests/integration/modules/sysmod.py
Erik Johnson 5a3c099e4f Rewrite the tests_valid_docs test
This uses a function in the runtests_helpers custom module to perform
all the logic, and only returns what failed the test. This saves us from
having to return the entire contents of sys.doc (as well as log all of
the function calls), and also removes the need to run sys.doc in batches
to get around the "max message size" issue.
2017-02-26 12:21:00 -06:00

38 lines
1.1 KiB
Python

# -*- coding: utf-8 -*-
# Import python libs
from __future__ import absolute_import
# Import Salt Testing libs
from salttesting.helpers import ensure_in_syspath
ensure_in_syspath('../../')
# Import salt libs
import integration
class SysModuleTest(integration.ModuleCase):
'''
Validate the sys module
'''
def test_valid_docs(self):
'''
Make sure no functions are exposed that don't have valid docstrings
'''
ret = self.run_function('runtests_helpers.get_invalid_docs')
if ret == {'missing_docstring': [], 'missing_cli_example': []}:
return
raise AssertionError(
'There are some functions which do not have a docstring or do not '
'have an example:\nNo docstring:\n{0}\nNo example:\n{1}\n'.format(
'\n'.join([' - {0}'.format(f) for f in ret['missing_docstring']]),
'\n'.join([' - {0}'.format(f) for f in ret['missing_cli_example']]),
)
)
if __name__ == '__main__':
from integration import run_tests
run_tests(SysModuleTest)