Skip to content

Commit d730dd0

Browse files
author
Alan Tan
committed
Add doctest for front_controller
1 parent 01fc932 commit d730dd0

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

patterns/structural/front_controller.py

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,23 @@ def __init__(self, request):
5858
self.type = self.tablet_type
5959

6060

61-
if __name__ == '__main__':
62-
front_controller = RequestController()
63-
front_controller.dispatch_request(Request('mobile'))
64-
front_controller.dispatch_request(Request('tablet'))
65-
66-
front_controller.dispatch_request(Request('desktop'))
67-
front_controller.dispatch_request('mobile')
68-
69-
70-
### OUTPUT ###
71-
# Displaying mobile index page
72-
# Displaying tablet index page
73-
# cant dispatch the request
74-
# request must be a Request object
61+
def main():
62+
"""
63+
>>> front_controller = RequestController()
64+
65+
>>> front_controller.dispatch_request(Request('mobile'))
66+
Displaying mobile index page
67+
68+
>>> front_controller.dispatch_request(Request('tablet'))
69+
Displaying tablet index page
70+
71+
>>> front_controller.dispatch_request(Request('desktop'))
72+
cant dispatch the request
73+
74+
>>> front_controller.dispatch_request('mobile')
75+
request must be a Request object
76+
"""
77+
78+
if __name__ == "__main__":
79+
import doctest
80+
doctest.testmod()

0 commit comments

Comments
 (0)