MCPcopy Index your code
hub / github.com/python/cpython / test_uninitialized

Method test_uninitialized

Lib/test/test_asyncio/test_futures.py:191–241  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

189 self.assertRaises(TypeError, self._new_future, 42)
190
191 def test_uninitialized(self):
192 # Test that C Future doesn't crash when Future.__init__()
193 # call was skipped.
194
195 fut = self.cls.__new__(self.cls, loop=self.loop)
196 self.assertRaises(asyncio.InvalidStateError, fut.result)
197
198 fut = self.cls.__new__(self.cls, loop=self.loop)
199 self.assertRaises(asyncio.InvalidStateError, fut.exception)
200
201 fut = self.cls.__new__(self.cls, loop=self.loop)
202 with self.assertRaises((RuntimeError, AttributeError)):
203 fut.set_result(None)
204
205 fut = self.cls.__new__(self.cls, loop=self.loop)
206 with self.assertRaises((RuntimeError, AttributeError)):
207 fut.set_exception(Exception)
208
209 fut = self.cls.__new__(self.cls, loop=self.loop)
210 with self.assertRaises((RuntimeError, AttributeError)):
211 fut.cancel()
212
213 fut = self.cls.__new__(self.cls, loop=self.loop)
214 with self.assertRaises((RuntimeError, AttributeError)):
215 fut.add_done_callback(lambda f: None)
216
217 fut = self.cls.__new__(self.cls, loop=self.loop)
218 with self.assertRaises((RuntimeError, AttributeError)):
219 fut.remove_done_callback(lambda f: None)
220
221 fut = self.cls.__new__(self.cls, loop=self.loop)
222 try:
223 repr(fut)
224 except (RuntimeError, AttributeError):
225 pass
226
227 fut = self.cls.__new__(self.cls, loop=self.loop)
228 try:
229 fut.__await__()
230 except RuntimeError:
231 pass
232
233 fut = self.cls.__new__(self.cls, loop=self.loop)
234 try:
235 iter(fut)
236 except RuntimeError:
237 pass
238
239 fut = self.cls.__new__(self.cls, loop=self.loop)
240 self.assertFalse(fut.cancelled())
241 self.assertFalse(fut.done())
242
243 def test_future_cancel_message_getter(self):
244 f = self._new_future(loop=self.loop)

Callers

nothing calls this directly

Calls 11

assertFalseMethod · 0.80
__new__Method · 0.45
assertRaisesMethod · 0.45
set_resultMethod · 0.45
set_exceptionMethod · 0.45
cancelMethod · 0.45
add_done_callbackMethod · 0.45
remove_done_callbackMethod · 0.45
__await__Method · 0.45
cancelledMethod · 0.45
doneMethod · 0.45

Tested by

no test coverage detected