Skip to content

Commit dfed341

Browse files
CPython Devleopersyouknowone
authored andcommitted
Upgrade unittest from 3.14.2
1 parent 5242ff5 commit dfed341

29 files changed

Lines changed: 826 additions & 179 deletions

Lib/test/test_unittest/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os.path
2+
23
from test.support import load_package_tests
34

45

Lib/test/test_unittest/__main__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from . import load_tests
21
import unittest
32

3+
from . import load_tests
4+
45
unittest.main()

Lib/test/test_unittest/_test_warnings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import unittest
1515
import warnings
1616

17+
1718
def warnfun():
1819
warnings.warn('rw', RuntimeWarning)
1920

Lib/test/test_unittest/test_assertions.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import datetime
2+
import unittest
23
import warnings
34
import weakref
4-
import unittest
5-
from test.support import gc_collect
65
from itertools import product
76

7+
from test.support import gc_collect
8+
89

910
class Test_Assertions(unittest.TestCase):
1011
def test_AlmostEqual(self):

Lib/test/test_unittest/test_async_case.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import asyncio
22
import contextvars
33
import unittest
4+
45
from test import support
6+
from test.support import force_not_colorized
57

68
support.requires_working_socket(module=True)
79

@@ -11,7 +13,7 @@ class MyException(Exception):
1113

1214

1315
def tearDownModule():
14-
asyncio.set_event_loop_policy(None)
16+
asyncio.events._set_event_loop_policy(None)
1517

1618

1719
class TestCM:
@@ -253,6 +255,7 @@ async def on_cleanup(self):
253255
test.doCleanups()
254256
self.assertEqual(events, ['asyncSetUp', 'test', 'asyncTearDown', 'cleanup'])
255257

258+
@force_not_colorized
256259
def test_exception_in_tear_clean_up(self):
257260
class Test(unittest.IsolatedAsyncioTestCase):
258261
async def asyncSetUp(self):
@@ -314,18 +317,21 @@ async def test3(self):
314317
self.assertIn('It is deprecated to return a value that is not None', str(w.warning))
315318
self.assertIn('test1', str(w.warning))
316319
self.assertEqual(w.filename, __file__)
320+
self.assertIn("returned 'int'", str(w.warning))
317321

318322
with self.assertWarns(DeprecationWarning) as w:
319323
Test('test2').run()
320324
self.assertIn('It is deprecated to return a value that is not None', str(w.warning))
321325
self.assertIn('test2', str(w.warning))
322326
self.assertEqual(w.filename, __file__)
327+
self.assertIn("returned 'async_generator'", str(w.warning))
323328

324329
with self.assertWarns(DeprecationWarning) as w:
325330
Test('test3').run()
326331
self.assertIn('It is deprecated to return a value that is not None', str(w.warning))
327332
self.assertIn('test3', str(w.warning))
328333
self.assertEqual(w.filename, __file__)
334+
self.assertIn(f'returned {Nothing.__name__!r}', str(w.warning))
329335

330336
def test_cleanups_interleave_order(self):
331337
events = []
@@ -477,7 +483,7 @@ def test_setup_get_event_loop(self):
477483

478484
class TestCase1(unittest.IsolatedAsyncioTestCase):
479485
def setUp(self):
480-
asyncio.get_event_loop_policy().get_event_loop()
486+
asyncio.events._get_event_loop_policy().get_event_loop()
481487

482488
async def test_demo1(self):
483489
pass
@@ -487,7 +493,7 @@ async def test_demo1(self):
487493
self.assertTrue(result.wasSuccessful())
488494

489495
def test_loop_factory(self):
490-
asyncio.set_event_loop_policy(None)
496+
asyncio.events._set_event_loop_policy(None)
491497

492498
class TestCase1(unittest.IsolatedAsyncioTestCase):
493499
loop_factory = asyncio.EventLoop

Lib/test/test_unittest/test_break.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import gc
22
import io
33
import os
4-
import sys
54
import signal
6-
import weakref
5+
import sys
76
import unittest
7+
import weakref
88

99
from test import support
1010

0 commit comments

Comments
 (0)