Skip to content

Commit 01fc932

Browse files
author
Alan Tan
committed
Add doctest for decorator
1 parent 76b6c24 commit 01fc932

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

patterns/structural/decorator.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,18 @@ def render(self):
5555
return "<i>{}</i>".format(self._wrapped.render())
5656

5757

58+
def main():
59+
"""
60+
>>> simple_hello = TextTag("hello, world!")
61+
>>> special_hello = ItalicWrapper(BoldWrapper(simple_hello))
62+
63+
>>> print("before:", simple_hello.render())
64+
before: hello, world!
65+
66+
>>> print("after:", special_hello.render())
67+
after: <i><b>hello, world!</b></i>
68+
"""
69+
5870
if __name__ == '__main__':
59-
simple_hello = TextTag("hello, world!")
60-
special_hello = ItalicWrapper(BoldWrapper(simple_hello))
61-
print("before:", simple_hello.render())
62-
print("after:", special_hello.render())
63-
64-
### OUTPUT ###
65-
# before: hello, world!
66-
# after: <i><b>hello, world!</b></i>
71+
import doctest
72+
doctest.testmod()

0 commit comments

Comments
 (0)