Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Address review
  • Loading branch information
sobolevn committed Jun 12, 2024
commit bb52da92d5a245119bf576d518cf1e071acc16ec
6 changes: 3 additions & 3 deletions Lib/test/test_unittest/test_async_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,21 +312,21 @@ async def test3(self):
self.assertIn('It is deprecated to return a value that is not None', str(w.warning))
self.assertIn('test1', str(w.warning))
self.assertEqual(w.filename, __file__)
self.assertIn("(<class 'int'>)", str(w.warning))
self.assertIn("('int')", str(w.warning))

with self.assertWarns(DeprecationWarning) as w:
Test('test2').run()
self.assertIn('It is deprecated to return a value that is not None', str(w.warning))
self.assertIn('test2', str(w.warning))
self.assertEqual(w.filename, __file__)
self.assertIn("(<class 'async_generator'>)", str(w.warning))
self.assertIn("('async_generator')", str(w.warning))

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

def test_cleanups_interleave_order(self):
events = []
Expand Down
8 changes: 4 additions & 4 deletions Lib/test/test_unittest/test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,21 +325,21 @@ def test3(self):
self.assertIn('It is deprecated to return a value that is not None', str(w.warning))
self.assertIn('test1', str(w.warning))
self.assertEqual(w.filename, __file__)
self.assertIn("(<class 'int'>)", str(w.warning))
self.assertIn("('int')", str(w.warning))

with self.assertWarns(DeprecationWarning) as w:
Foo('test2').run()
self.assertIn('It is deprecated to return a value that is not None', str(w.warning))
self.assertIn('test2', str(w.warning))
self.assertEqual(w.filename, __file__)
self.assertIn("(<class 'generator'>)", str(w.warning))
self.assertIn("('generator')", str(w.warning))

with self.assertWarns(DeprecationWarning) as w:
Foo('test3').run()
self.assertIn('It is deprecated to return a value that is not None', str(w.warning))
self.assertIn('test3', str(w.warning))
self.assertEqual(w.filename, __file__)
self.assertIn(f'({Nothing})', str(w.warning))
self.assertIn(f'({Nothing.__name__!r})', str(w.warning))

def test_deprecation_of_return_val_from_test_async_method(self):
class Foo(unittest.TestCase):
Expand All @@ -351,7 +351,7 @@ async def test1(self):
self.assertIn('It is deprecated to return a value that is not None', str(w.warning))
self.assertIn('test1', str(w.warning))
self.assertEqual(w.filename, __file__)
self.assertIn("(<class 'coroutine'>)", str(w.warning))
self.assertIn("('coroutine')", str(w.warning))
self.assertIn(
(
"a coroutine is returned, "
Expand Down
2 changes: 1 addition & 1 deletion Lib/unittest/async_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def _callTestMethod(self, method):
if (result := self._callMaybeAsync(method)) is not None:
Comment thread
sobolevn marked this conversation as resolved.
Outdated
msg = (
'It is deprecated to return a value that is not None, '
f'got: ({type(result)}) from a '
f'got: ({type(result).__name__!r}) from a '
f'test case ({method})',
)
Comment thread
sobolevn marked this conversation as resolved.
warnings.warn(msg, DeprecationWarning, stacklevel=4)
Expand Down
2 changes: 1 addition & 1 deletion Lib/unittest/case.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ def _callTestMethod(self, method):
from unittest.async_case import IsolatedAsyncioTestCase
Comment thread
sobolevn marked this conversation as resolved.
Outdated
msg = (
'It is deprecated to return a value that is not None, '
f'got: ({type(result)}) from a '
f'got: ({type(result).__name__!r}) from a '
f'test case ({method})'
)
if (
Expand Down