File: test_docstrings.py

package info (click to toggle)
python-semver 3.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 700 kB
  • sloc: python: 1,972; makefile: 28
file content (39 lines) | stat: -rw-r--r-- 1,062 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import inspect

import pytest

import semver


def getallfunctions(module=semver):
    def getfunctions(_module):
        for _, func in inspect.getmembers(_module, inspect.isfunction):
            # Make sure you only investigate functions from our modules:
            if not func.__name__.startswith("_") and func.__module__.startswith(
                _module.__name__
            ):
                yield func

    def getmodules(_module):
        for _, m in inspect.getmembers(_module, inspect.ismodule):
            if m.__package__.startswith(_module.__package__):
                yield m

    for ff in getfunctions(module):
        yield ff
    # for mm in getmodules(module):
    #    for ff in getfunctions(mm):
    #        yield ff


SEMVERFUNCS = [func for func in getallfunctions()]


@pytest.mark.parametrize(
    "func", SEMVERFUNCS, ids=[func.__name__ for func in SEMVERFUNCS]
)
def test_fordocstrings(func):
    assert func.__doc__, "Need a docstring for function %r from module %r" % (
        func.__name__,
        func.__module__,
    )