Clarify the role and meaning of self.fetch() in AsyncHTTPTestCase.
The example code should just show the simple, obvious thing to do: call self.fetch(). Text afterwards explains how this relates to stop() and wait().
This commit is contained in:
parent
5039d3d28b
commit
177e03415a
|
@ -338,13 +338,17 @@ class AsyncHTTPTestCase(AsyncTestCase):
|
||||||
return Application([('/', MyHandler)...])
|
return Application([('/', MyHandler)...])
|
||||||
|
|
||||||
def test_homepage(self):
|
def test_homepage(self):
|
||||||
# The following two lines are equivalent to
|
response = self.fetch('/')
|
||||||
# response = self.fetch('/')
|
|
||||||
# but are shown in full here to demonstrate explicit use
|
That call to ``self.fetch()`` is equivalent to ::
|
||||||
# of self.stop and self.wait.
|
|
||||||
self.http_client.fetch(self.get_url('/'), self.stop)
|
self.http_client.fetch(self.get_url('/'), self.stop)
|
||||||
response = self.wait()
|
response = self.wait()
|
||||||
# test contents of response
|
|
||||||
|
which illustrates how AsyncTestCase can turn an asynchronous operation,
|
||||||
|
like ``http_client.fetch()``, into a synchronous operation. If you need
|
||||||
|
to do other asynchronous operations in tests, you'll probably need to use
|
||||||
|
``stop()`` and ``wait()`` yourself.
|
||||||
"""
|
"""
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(AsyncHTTPTestCase, self).setUp()
|
super(AsyncHTTPTestCase, self).setUp()
|
||||||
|
|
Loading…
Reference in New Issue