Пример #1
0
def test_abjad___doc___01(class_):
    r'''All classes have a docstring. All class methods have a docstring.
    '''
    missing_doc_names = []
    if class_.__doc__ is None:
        missing_doc_names.append(class_.__name__)
    for attribute in inspect.classify_class_attrs(class_):
        if attribute.name in ignored_names:
            continue
        elif attribute.defining_class is not class_:
            continue
        if attribute.name[0].isalpha() or attribute.name.startswith('__'):
            if getattr(class_, attribute.name).__doc__ is None:
                missing_doc_names.append(attribute.name)
    if missing_doc_names:
        names = [class_.__name__ + '.' + _ for _ in missing_doc_names]
        names = ', '.join(names)
        message = 'Missing docstrings for: {}'
        message = message.format(names)
        raise Exception(message)


functions = documentationtools.list_all_abjad_functions()
if functions:

    @pytest.mark.parametrize('function', functions)
    def test_abjad___doc___02(function):
        r'''All old functions had a docstring.
        '''
        assert function.__doc__ is not None
Пример #2
0
        obj = attr.object
        if isinstance(obj, functools.partial):
            obj = obj.function
        argument_specification = inspect.getargspec(obj)
        keyword_argument_names = argument_specification.args[1:]
        keyword_argument_values = argument_specification.defaults
        if keyword_argument_values is None:
            continue
        for name, value in zip(
            keyword_argument_names, keyword_argument_values):
            assert isinstance(value, valid_types), (attr.name, name, value)
            if isinstance(value, tuple):
                assert all(isinstance(x, valid_types) for x in value)


functions = documentationtools.list_all_abjad_functions()
@pytest.mark.parametrize('obj', functions)
def test_abjad___init___03(obj):
    r'''Make sure function keyword argument values are immutable.
    '''
    if isinstance(obj, functools.partial):
        obj = obj.function
    argument_specification = inspect.getargspec(obj)
    keyword_argument_names = argument_specification.args[1:]
    keyword_argument_values = argument_specification.defaults
    if keyword_argument_values is None:
        return
    for name, value in zip(
        keyword_argument_names, keyword_argument_values):
        assert isinstance(value, valid_types), (name, value)
        if isinstance(value, tuple):