-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
98 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
"""Module for testing pattern "Iterator".""" | ||
|
||
|
||
import pytest | ||
|
||
from patterns.chapter_09_iterator.menus import DinerMenu, Menu, PancackeMenu | ||
from patterns.chapter_09_iterator.waitress import Waitress | ||
|
||
pytestmark = pytest.mark.parametrize( | ||
('menu', 'menu_items'), | ||
[ | ||
(PancackeMenu(), {'pancake': 1.99, 'waffle': 2.99}), | ||
(DinerMenu(), [('spaghetti', 3.99)]), | ||
], | ||
) | ||
|
||
|
||
def test_iterator_pattern( | ||
capsys, | ||
menu: Menu, | ||
menu_items: list[tuple[str, float]] | dict[str, float], | ||
) -> None: | ||
"""Test iterator pattern. | ||
Printing all menus must be unified even if menu_items are of different | ||
types. | ||
""" | ||
menu.set_items(menu_items) | ||
|
||
Waitress([menu]).print_all_menus() | ||
captured = capsys.readouterr() | ||
|
||
assert str(menu) in captured.out |