Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit df0ac36

Browse files
New tests for better covering of tuples inside with statements (psf#4650)
Co-authored-by: cobalt <[email protected]>
1 parent 60d734a commit df0ac36

2 files changed

Lines changed: 30 additions & 39 deletions

File tree

tests/data/cases/context_managers_39.py

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -90,25 +90,6 @@ async def func():
9090
pass
9191

9292

93-
# don't remove the brackets here, it changes the meaning of the code.
94-
# even though the code will always trigger a runtime error
95-
with (name_5, name_4), name_5:
96-
pass
97-
98-
99-
def test_tuple_as_contextmanager():
100-
from contextlib import nullcontext
101-
102-
try:
103-
with (nullcontext(),nullcontext()),nullcontext():
104-
pass
105-
except TypeError:
106-
# test passed
107-
pass
108-
else:
109-
# this should be a type error
110-
assert False
111-
11293
# output
11394

11495

@@ -202,23 +183,3 @@ async def func():
202183
# don't remove the brackets here, it changes the meaning of the code.
203184
with (x, y) as z:
204185
pass
205-
206-
207-
# don't remove the brackets here, it changes the meaning of the code.
208-
# even though the code will always trigger a runtime error
209-
with (name_5, name_4), name_5:
210-
pass
211-
212-
213-
def test_tuple_as_contextmanager():
214-
from contextlib import nullcontext
215-
216-
try:
217-
with (nullcontext(), nullcontext()), nullcontext():
218-
pass
219-
except TypeError:
220-
# test passed
221-
pass
222-
else:
223-
# this should be a type error
224-
assert False
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# don't remove the brackets here, it changes the meaning of the code.
2+
# even though the code will always trigger a runtime error
3+
with (name_5, name_4), name_5:
4+
pass
5+
6+
7+
with c, (a, b):
8+
pass
9+
10+
11+
with c, (a, b), d:
12+
pass
13+
14+
15+
with c, (a, b, e, f, g), d:
16+
pass
17+
18+
19+
def test_tuple_as_contextmanager():
20+
from contextlib import nullcontext
21+
22+
try:
23+
with (nullcontext(), nullcontext()), nullcontext():
24+
pass
25+
except TypeError:
26+
# test passed
27+
pass
28+
else:
29+
# this should be a type error
30+
assert False

0 commit comments

Comments
 (0)