Skip to content

Commit 2d4a555

Browse files
committed
Add doctest for builder
1 parent e498b66 commit 2d4a555

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

patterns/creational/builder.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -91,18 +91,23 @@ def construct_building(cls):
9191
return building
9292

9393

94-
# Client
95-
if __name__ == "__main__":
96-
house = House()
97-
print(house)
98-
flat = Flat()
99-
print(flat)
94+
def main():
95+
"""
96+
>>> house = House()
97+
>>> house
98+
Floor: One | Size: Big
99+
100+
>>> flat = Flat()
101+
>>> flat
102+
Floor: More than One | Size: Small
100103
101104
# Using an external constructor function:
102-
complex_house = construct_building(ComplexHouse)
103-
print(complex_house)
105+
>>> complex_house = construct_building(ComplexHouse)
106+
>>> complex_house
107+
Floor: One | Size: Big and fancy
108+
"""
104109

105-
### OUTPUT ###
106-
# Floor: One | Size: Big
107-
# Floor: More than One | Size: Small
108-
# Floor: One | Size: Big and fancy
110+
111+
if __name__ == "__main__":
112+
import doctest
113+
doctest.testmod()

0 commit comments

Comments
 (0)