Add context manager test...

handle degenerate 3.8 withas
This commit is contained in:
rocky
2024-03-07 18:08:07 -05:00
parent b5c4e4b28b
commit 8542df4639
6 changed files with 64 additions and 14 deletions

View File

@@ -0,0 +1,21 @@
"""
This program is self checking!
"""
class TestContextManager:
def __enter__(self):
return 1, 2
def __exit__(self, exc_type, exc_value, exc_tb):
return self, exc_type, exc_value, exc_tb
with open(__file__) as a:
assert a
with open(__file__) as a, open(__file__) as b:
assert a.read() == b.read()
with TestContextManager() as a, b:
assert (a, b) == (1, 2)