Testing Builder Pattern Building Construction in python-patterns
This test suite validates the Builder pattern implementation for creating different types of buildings (House, Flat, ComplexHouse) in Python. It verifies both simple and complex construction scenarios through dedicated test classes.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
faif/python-patterns
tests/creational/test_builder.py
import unittest
from patterns.creational.builder import ComplexHouse, Flat, House, construct_building
class TestSimple(unittest.TestCase):
def test_house(self):
house = House()
self.assertEqual(house.size, "Big")
self.assertEqual(house.floor, "One")
def test_flat(self):
flat = Flat()
self.assertEqual(flat.size, "Small")
self.assertEqual(flat.floor, "More than One")
class TestComplex(unittest.TestCase):
def test_house(self):
house = construct_building(ComplexHouse)
self.assertEqual(house.size, "Big and fancy")
self.assertEqual(house.floor, "One")