MCPcopy Create free account
hub / github.com/pyinvoke/invoke / repr

Class repr

tests/parser_argument.py:37–69  ·  view source on GitHub ↗

__repr__

Source from the content-addressed store, hash-verified

35 assert a.name == "bar" # not 'foo'
36
37 class repr:
38 "__repr__"
39
40 def shows_useful_info(self):
41 arg = Argument(names=("name", "nick1", "nick2"))
42 expected = "<Argument: {} ({})>".format("name", "nick1, nick2")
43 assert repr(arg) == expected
44
45 def does_not_show_nickname_parens_if_no_nicknames(self):
46 assert repr(Argument("name")) == "<Argument: name>"
47
48 def shows_positionalness(self):
49 arg = Argument("name", positional=True)
50 assert repr(arg) == "<Argument: name *>"
51
52 def shows_optionalness(self):
53 arg = Argument("name", optional=True)
54 assert repr(arg) == "<Argument: name ?>"
55
56 def positionalness_and_optionalness_stick_together(self):
57 # TODO: but do these even make sense on the same argument? For now,
58 # best to have a nonsensical test than a missing one...
59 arg = Argument("name", optional=True, positional=True)
60 assert repr(arg) == "<Argument: name *?>"
61
62 def shows_kind_if_not_str(self):
63 assert repr(Argument("age", kind=int)) == "<Argument: age [int]>"
64
65 def all_the_things_together(self):
66 arg = Argument(
67 names=("meh", "m"), kind=int, optional=True, positional=True
68 )
69 assert repr(arg) == "<Argument: meh (m) [int] *?>"
70
71 class kind_kwarg:
72 "'kind' kwarg"

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…