File: util.py

package info (click to toggle)
python-invoke 1.4.1%2Bds-0.1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,704 kB
  • sloc: python: 11,377; makefile: 18; sh: 12
file content (58 lines) | stat: -rw-r--r-- 1,509 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
from invoke.util import helpline


class util:
    class helpline:
        def is_None_if_no_docstring(self):
            def foo(c):
                pass

            assert helpline(foo) is None

        def is_entire_thing_if_docstring_one_liner(self):
            def foo(c):
                "foo!"
                pass

            assert helpline(foo) == "foo!"

        def left_strips_newline_bearing_one_liners(self):
            def foo(c):
                """
                foo!
                """
                pass

            assert helpline(foo) == "foo!"

        def is_first_line_in_multiline_docstrings(self):
            def foo(c):
                """
                foo?

                foo!
                """
                pass

            assert helpline(foo) == "foo?"

        def is_None_if_docstring_matches_object_type(self):
            # I.e. we don't want a docstring that is coming from the class
            # instead of the instance.
            class Foo(object):
                "I am Foo"
                pass

            foo = Foo()
            assert helpline(foo) is None

        def instance_attached_docstring_is_still_displayed(self):
            # This is actually a property of regular object semantics, but
            # whatever, why not have a test for it.
            class Foo(object):
                "I am Foo"
                pass

            foo = Foo()
            foo.__doc__ = "I am foo"
            assert helpline(foo) == "I am foo"