gh-71339: Use new assertion methods in test_asyncio (#129051)

This commit is contained in:
Serhiy Storchaka 2025-01-20 13:32:39 +02:00 committed by GitHub
parent 6f167d7134
commit c6b570e5e3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 36 additions and 37 deletions

View file

@ -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)))