File tree Expand file tree Collapse file tree 1 file changed +26
-23
lines changed Expand file tree Collapse file tree 1 file changed +26
-23
lines changed Original file line number Diff line number Diff line change @@ -75,29 +75,32 @@ def random_animal():
75
75
76
76
77
77
# Show pets with various factories
78
- if __name__ == "__main__" :
79
-
78
+ def main () :
79
+ """
80
80
# A Shop that sells only cats
81
- cat_shop = PetShop (Cat )
82
- cat_shop .show_pet ()
83
- print ("" )
81
+ >>> cat_shop = PetShop(Cat)
82
+ >>> cat_shop.show_pet()
83
+ We have a lovely Cat
84
+ It says meow
84
85
85
86
# A shop that sells random animals
86
- shop = PetShop (random_animal )
87
- for i in range (3 ):
88
- shop .show_pet ()
89
- print ("=" * 20 )
90
-
91
- ### OUTPUT ###
92
- # We have a lovely Cat
93
- # It says meow
94
- #
95
- # We have a lovely Dog
96
- # It says woof
97
- # ====================
98
- # We have a lovely Cat
99
- # It says meow
100
- # ====================
101
- # We have a lovely Cat
102
- # It says meow
103
- # ====================
87
+ >>> shop = PetShop(random_animal)
88
+ >>> for i in range(3):
89
+ ... shop.show_pet()
90
+ ... print("=" * 20)
91
+ We have a lovely Cat
92
+ It says meow
93
+ ====================
94
+ We have a lovely Dog
95
+ It says woof
96
+ ====================
97
+ We have a lovely Dog
98
+ It says woof
99
+ ====================
100
+ """
101
+
102
+
103
+ if __name__ == "__main__" :
104
+ random .seed (1234 ) # for deterministic doctest outputs
105
+ import doctest
106
+ doctest .testmod ()
You can’t perform that action at this time.
0 commit comments