Skip to content

Commit cc04c6f

Browse files
committed
Merge two tests (2)
1 parent c6cc066 commit cc04c6f

File tree

1 file changed

+8
-21
lines changed

1 file changed

+8
-21
lines changed

Lib/test/datetimetester.py

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7338,11 +7338,12 @@ def test_static_type_on_subinterp(self):
73387338
with self.subTest('Implicit import'):
73397339
self.assert_python_in_subinterp(True, script4)
73407340

7341-
def test_static_type_at_shutdown1(self):
7341+
def test_static_type_at_shutdown(self):
73427342
# gh-132413
73437343
script = textwrap.dedent("""
73447344
import sys
73457345
import _datetime
7346+
timedelta = _datetime.timedelta
73467347
73477348
def gen():
73487349
try:
@@ -7352,33 +7353,19 @@ def gen():
73527353
assert not sys.modules
73537354
td = _datetime.timedelta(days=1)
73547355
assert td.days == 1
7355-
assert not sys.modules
7356-
7357-
it = gen()
7358-
next(it)
7359-
""")
7360-
res = script_helper.assert_python_ok('-c', script)
7361-
self.assertFalse(res.err)
7362-
7363-
def test_static_type_at_shutdown2(self):
7364-
script = textwrap.dedent("""
7365-
import sys
7366-
from _datetime import timedelta
7367-
7368-
def gen():
7369-
try:
7370-
yield
7371-
finally:
7372-
assert not sys.modules
73737356
td = timedelta(days=1)
73747357
assert td.days == 1
73757358
assert not sys.modules
73767359
73777360
it = gen()
73787361
next(it)
73797362
""")
7380-
res = script_helper.assert_python_ok('-c', script)
7381-
self.assertFalse(res.err)
7363+
with self.subTest('MainInterpreter'):
7364+
res = script_helper.assert_python_ok('-c', script)
7365+
self.assertFalse(res.err)
7366+
with self.subTest('Subinterpreter'):
7367+
res = self.assert_python_in_subinterp(True, script, setup='')
7368+
self.assertFalse(res.err)
73827369

73837370
def test_static_type_at_shutdown3(self):
73847371
script = textwrap.dedent("""

0 commit comments

Comments
 (0)