File: docstring_vows.py

package info (click to toggle)
pyvows 3.0.0-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 500 kB
  • sloc: python: 3,884; makefile: 19; sh: 8
file content (62 lines) | stat: -rw-r--r-- 1,258 bytes parent folder | download | duplicates (4)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# -*- coding: utf-8 -*-

import types

from pyvows import Vows, expect


from pyvows import (
    __init__ as pyvows_init,
    __main__,
    async_topic,
    color,
    cli,
    core,
    runner,
    version)
from pyvows.reporting import (
    __init__ as reporting_init,
    common as reporting_common,
    coverage as reporting_coverage,
    profile as reporting_profile,
    test as reporting_test,
    xunit as reporting_xunit)

PYVOWS_MODULES = (
    # general modules
    pyvows_init,
    __main__,
    async_topic,
    color,
    cli,
    core,
    runner,
    version,
    # reporting
    reporting_init,
    reporting_common,
    reporting_coverage,
    reporting_profile,
    reporting_test,
    reporting_xunit,)


@Vows.assertion
def to_have_a_docstring(topic):
    '''Custom assertion.  Raises a AssertionError if `topic` has no
    docstring.

    '''
    if not hasattr(topic, '__doc__'):
        raise AssertionError('Expected topic({0}) to have a docstring', topic)


@Vows.batch
class EachPyvowsModule(Vows.Context):
    def topic(self):
        for mod in PYVOWS_MODULES:
            if isinstance(mod, types.ModuleType):
                yield mod

    def should_have_a_docstring(self, topic):
        expect(topic).to_have_a_docstring()