Skip to content

Commit a77c79c

Browse files
author
Alan Tan
committed
Add doctest for mvc
1 parent d730dd0 commit a77c79c

File tree

1 file changed

+35
-28
lines changed

1 file changed

+35
-28
lines changed

patterns/structural/mvc.py

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -110,31 +110,38 @@ def show_item_information(self, item_name):
110110
self.view.show_item_information(item_type, item_name, item_info)
111111

112112

113-
if __name__ == "__main__":
114-
115-
model = ProductModel()
116-
view = ConsoleView()
117-
controller = Controller(model, view)
118-
controller.show_items()
119-
controller.show_item_information("cheese")
120-
controller.show_item_information("eggs")
121-
controller.show_item_information("milk")
122-
controller.show_item_information("arepas")
123-
124-
125-
### OUTPUT ###
126-
# PRODUCT LIST:
127-
# cheese
128-
# eggs
129-
# milk
130-
#
131-
# PRODUCT INFORMATION:
132-
# Name: Cheese, Price: 2.00, Quantity: 10
133-
#
134-
# PRODUCT INFORMATION:
135-
# Name: Eggs, Price: 0.20, Quantity: 100
136-
#
137-
# PRODUCT INFORMATION:
138-
# Name: Milk, Price: 1.50, Quantity: 10
139-
#
140-
# That product "arepas" does not exist in the records
113+
def main():
114+
"""
115+
>>> model = ProductModel()
116+
>>> view = ConsoleView()
117+
>>> controller = Controller(model, view)
118+
119+
>>> controller.show_items()
120+
PRODUCT LIST:
121+
milk
122+
eggs
123+
cheese
124+
<BLANKLINE>
125+
126+
>>> controller.show_item_information("cheese")
127+
PRODUCT INFORMATION:
128+
Name: cheese, Price: 2.00, Quantity: 10
129+
<BLANKLINE>
130+
131+
>>> controller.show_item_information("eggs")
132+
PRODUCT INFORMATION:
133+
Name: eggs, Price: 0.20, Quantity: 100
134+
<BLANKLINE>
135+
136+
>>> controller.show_item_information("milk")
137+
PRODUCT INFORMATION:
138+
Name: milk, Price: 1.50, Quantity: 10
139+
<BLANKLINE>
140+
141+
>>> controller.show_item_information("arepas")
142+
That product "arepas" does not exist in the records
143+
"""
144+
145+
if __name__ == '__main__':
146+
import doctest
147+
doctest.testmod()

0 commit comments

Comments
 (0)