diff options
author | Kumar Aditya <rahuladitya303@gmail.com> | 2021-12-06 23:40:35 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-06 23:40:35 (GMT) |
commit | 265918bb1d782ab85c7dbc835eb62d6cfc2145b7 (patch) | |
tree | d3f63cd07b8465aed76dfc04839d388c28bf87c2 /Lib/test | |
parent | 8518ee348c18da7e150f5e42b3424c86f7c0a3d8 (diff) | |
download | cpython-265918bb1d782ab85c7dbc835eb62d6cfc2145b7.zip cpython-265918bb1d782ab85c7dbc835eb62d6cfc2145b7.tar.gz cpython-265918bb1d782ab85c7dbc835eb62d6cfc2145b7.tar.bz2 |
bpo-23819: asyncio: Replace AssertionError with TypeError where it makes sense (GH-29894)
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_asyncio/test_base_events.py | 4 | ||||
-rw-r--r-- | Lib/test/test_asyncio/test_events.py | 8 |
2 files changed, 6 insertions, 6 deletions
diff --git a/Lib/test/test_asyncio/test_base_events.py b/Lib/test/test_asyncio/test_base_events.py index b522fac..d812bc9 100644 --- a/Lib/test/test_asyncio/test_base_events.py +++ b/Lib/test/test_asyncio/test_base_events.py @@ -255,6 +255,8 @@ class BaseEventLoopTests(test_utils.TestCase): self.assertIsInstance(h, asyncio.TimerHandle) self.assertIn(h, self.loop._scheduled) self.assertNotIn(h, self.loop._ready) + with self.assertRaises(TypeError, msg="delay must not be None"): + self.loop.call_later(None, cb) def test_call_later_negative_delays(self): calls = [] @@ -286,6 +288,8 @@ class BaseEventLoopTests(test_utils.TestCase): # tolerate a difference of +800 ms because some Python buildbots # are really slow self.assertLessEqual(dt, 0.9, dt) + with self.assertRaises(TypeError, msg="when cannot be None"): + self.loop.call_at(None, cb) def check_thread(self, loop, debug): def cb(): diff --git a/Lib/test/test_asyncio/test_events.py b/Lib/test/test_asyncio/test_events.py index e50a53d..fe791fa 100644 --- a/Lib/test/test_asyncio/test_events.py +++ b/Lib/test/test_asyncio/test_events.py @@ -2322,10 +2322,6 @@ class TimerTests(unittest.TestCase): self.assertIsNone(h._callback) self.assertIsNone(h._args) - # when cannot be None - self.assertRaises(AssertionError, - asyncio.TimerHandle, None, callback, args, - self.loop) def test_timer_repr(self): self.loop.get_debug.return_value = False @@ -2592,7 +2588,7 @@ class PolicyTests(unittest.TestCase): policy = asyncio.DefaultEventLoopPolicy() old_loop = policy.get_event_loop() - self.assertRaises(AssertionError, policy.set_event_loop, object()) + self.assertRaises(TypeError, policy.set_event_loop, object()) loop = policy.new_event_loop() policy.set_event_loop(loop) @@ -2608,7 +2604,7 @@ class PolicyTests(unittest.TestCase): def test_set_event_loop_policy(self): self.assertRaises( - AssertionError, asyncio.set_event_loop_policy, object()) + TypeError, asyncio.set_event_loop_policy, object()) old_policy = asyncio.get_event_loop_policy() |