chore: initialize containerized Python learning workbook (2026 DevOps/SRE)
This commit is contained in:
commit
ae4c421815
63 files changed
+1273
No files matched your search
@@ -0,0 +1,16 @@
|
||||
import pytest
|
||||
from patterns_ex import ManagedFlag, apply_discount, percentage_discount
|
||||
|
||||
|
||||
def test_strategy_discount() -> None:
|
||||
discount_20 = percentage_discount(20)
|
||||
assert apply_discount(1000, discount_20) == 800
|
||||
|
||||
|
||||
def test_context_manager_cleans_up_even_on_error() -> None:
|
||||
flag = ManagedFlag()
|
||||
assert flag.active is False
|
||||
with pytest.raises(RuntimeError), flag as entered:
|
||||
assert entered.active is True
|
||||
raise RuntimeError("boom")
|
||||
assert flag.active is False
|
||||
Reference in new issue
Block a user