Debian Codegraph @

tests/util.py

raw
1 from invoke.util import helpline
2
3
4 class util:
5 class helpline:
6 def is_None_if_no_docstring(self):
7 def foo(c):
8 pass
9
10 assert helpline(foo) is None
11
12 def is_None_if_whitespace_only_docstring(self):
13 def foo(c):
14 """ """
15 pass
16
17 assert helpline(foo) is None
18
19 def is_entire_thing_if_docstring_one_liner(self):
20 def foo(c):
21 "foo!"
22 pass
23
24 assert helpline(foo) == "foo!"
25
26 def left_strips_newline_bearing_one_liners(self):
27 def foo(c):
28 """
29 foo!
30 """
31 pass
32
33 assert helpline(foo) == "foo!"
34
35 def is_first_line_in_multiline_docstrings(self):
36 def foo(c):
37 """
38 foo?
39
40 foo!
41 """
42 pass
43
44 assert helpline(foo) == "foo?"
45
46 def is_None_if_docstring_matches_object_type(self):
47 # I.e. we don't want a docstring that is coming from the class
48 # instead of the instance.
49 class Foo:
50 "I am Foo"
51
52 pass
53
54 foo = Foo()
55 assert helpline(foo) is None
56
57 def instance_attached_docstring_is_still_displayed(self):
58 # This is actually a property of regular object semantics, but
59 # whatever, why not have a test for it.
60 class Foo:
61 "I am Foo"
62
63 pass
64
65 foo = Foo()
66 foo.__doc__ = "I am foo"
67 assert helpline(foo) == "I am foo"