/
GlebBavykin
/
python_sketches
Обзор
Документация
Войти
/
GlebBavykin
/
python_sketches
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
main
tests/design_patterns/strucutral/test_bridge_pattern.py
37 строк
955 B
Gleb Bavykin
renaming
11 июл 2026, 19:01
11 июл 2026, 19:01
4a59f68
Код
Авторство
О чём код?
from copy import deepcopy import pytest from design_patterns.structural.bridge import Circle, Color, Rectangle, Shape @pytest.mark.parametrize( "new_color", [ Color.RED, Color.BLACK, Color.WHITE, ], ) @pytest.mark.parametrize( "shape_instance", [ Circle(radius=10), Rectangle(width=100, height=100), ], ) def test_bridge_pattern(shape_instance: Shape, new_color: Color): """ Test bridge pattern: Change color without creating a new shape instance """ old_shape_instance = deepcopy(shape_instance) assert shape_instance.color != new_color assert new_color.__str__() not in shape_instance.__repr__() assert old_shape_instance.color == shape_instance.color shape_instance.color = new_color assert shape_instance.color == new_color assert new_color.__str__() in shape_instance.__repr__() assert old_shape_instance.color != shape_instance.color