mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
gh-71339: Use new assertion methods in test_asyncio (#129051)
This commit is contained in:
parent
6f167d7134
commit
c6b570e5e3
10 changed files with 36 additions and 37 deletions
|
|
@ -27,11 +27,11 @@ class LockTests(unittest.IsolatedAsyncioTestCase):
|
|||
|
||||
async def test_repr(self):
|
||||
lock = asyncio.Lock()
|
||||
self.assertTrue(repr(lock).endswith('[unlocked]>'))
|
||||
self.assertEndsWith(repr(lock), '[unlocked]>')
|
||||
self.assertTrue(RGX_REPR.match(repr(lock)))
|
||||
|
||||
await lock.acquire()
|
||||
self.assertTrue(repr(lock).endswith('[locked]>'))
|
||||
self.assertEndsWith(repr(lock), '[locked]>')
|
||||
self.assertTrue(RGX_REPR.match(repr(lock)))
|
||||
|
||||
async def test_lock(self):
|
||||
|
|
@ -286,12 +286,12 @@ class EventTests(unittest.IsolatedAsyncioTestCase):
|
|||
|
||||
def test_repr(self):
|
||||
ev = asyncio.Event()
|
||||
self.assertTrue(repr(ev).endswith('[unset]>'))
|
||||
self.assertEndsWith(repr(ev), '[unset]>')
|
||||
match = RGX_REPR.match(repr(ev))
|
||||
self.assertEqual(match.group('extras'), 'unset')
|
||||
|
||||
ev.set()
|
||||
self.assertTrue(repr(ev).endswith('[set]>'))
|
||||
self.assertEndsWith(repr(ev), '[set]>')
|
||||
self.assertTrue(RGX_REPR.match(repr(ev)))
|
||||
|
||||
ev._waiters.append(mock.Mock())
|
||||
|
|
@ -916,11 +916,11 @@ class SemaphoreTests(unittest.IsolatedAsyncioTestCase):
|
|||
|
||||
async def test_repr(self):
|
||||
sem = asyncio.Semaphore()
|
||||
self.assertTrue(repr(sem).endswith('[unlocked, value:1]>'))
|
||||
self.assertEndsWith(repr(sem), '[unlocked, value:1]>')
|
||||
self.assertTrue(RGX_REPR.match(repr(sem)))
|
||||
|
||||
await sem.acquire()
|
||||
self.assertTrue(repr(sem).endswith('[locked]>'))
|
||||
self.assertEndsWith(repr(sem), '[locked]>')
|
||||
self.assertTrue('waiters' not in repr(sem))
|
||||
self.assertTrue(RGX_REPR.match(repr(sem)))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue