]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
docs: Remove empty testoutput blocks
authorBen Darnell <ben@bendarnell.com>
Wed, 12 Jun 2024 02:21:20 +0000 (22:21 -0400)
committerBen Darnell <ben@bendarnell.com>
Wed, 12 Jun 2024 02:21:20 +0000 (22:21 -0400)
These were once needed (I think) to get the tests to run at all, even
though they triggered warnings from sphinx. Now it works without them.

13 files changed:
docs/guide/async.rst
docs/guide/coroutines.rst
docs/guide/running.rst
docs/guide/security.rst
docs/guide/structure.rst
docs/guide/templates.rst
tornado/auth.py
tornado/gen.py
tornado/ioloop.py
tornado/iostream.py
tornado/web.py
tornado/websocket.py
tox.ini

index 1b5526ffc508de654894aefafaccc329b99de31b..5e545df75823f5b89bc337efac7ad1748f03254f 100644 (file)
@@ -73,9 +73,6 @@ Here is a sample synchronous function:
         response = http_client.fetch(url)
         return response.body
 
-.. testoutput::
-   :hide:
-
 And here is the same function rewritten asynchronously as a native coroutine:
 
 .. testcode::
@@ -87,9 +84,6 @@ And here is the same function rewritten asynchronously as a native coroutine:
        response = await http_client.fetch(url)
        return response.body
 
-.. testoutput::
-   :hide:
-
 Or for compatibility with older versions of Python, using the `tornado.gen` module:
 
 ..  testcode::
@@ -118,9 +112,6 @@ Coroutines are a little magical, but what they do internally is something like t
         fetch_future.add_done_callback(on_fetch)
         return my_future
 
-.. testoutput::
-   :hide:
-
 Notice that the coroutine returns its `.Future` before the fetch is
 done. This is what makes coroutines *asynchronous*.
 
index 811c084f1a3177a672b67012f9db79ab4e0972eb..691fa305b6a5fb53b967014f7a17521342ae23da 100644 (file)
@@ -207,9 +207,6 @@ The `.multi` function accepts lists and dicts whose values are
                                  for url in urls})
         # responses is a dict {url: HTTPResponse}
 
-.. testoutput::
-   :hide:
-
 In decorated coroutines, it is possible to ``yield`` the list or dict directly::
 
     @gen.coroutine
@@ -238,9 +235,6 @@ immediately, so you can start another operation before waiting.
             fetch_future = convert_yielded(self.fetch_next_chunk())
             await self.flush()
 
-.. testoutput::
-   :hide:
-
 This is a little easier to do with decorated coroutines, because they
 start immediately when called:
 
@@ -256,9 +250,6 @@ start immediately when called:
             fetch_future = self.fetch_next_chunk()
             yield self.flush()
 
-.. testoutput::
-   :hide:
-
 Looping
 ^^^^^^^
 
index 99d18275a35960a55dbb19e170b6358493964e8b..8c7fda818b5c27021c811d25e5e9f8be39743efd 100644 (file)
@@ -18,9 +18,6 @@ configuring a WSGI container to find your application, you write a
     if __name__ == '__main__':
         asyncio.run(main())
 
-.. testoutput::
-   :hide:
-
 Configure your operating system or process manager to run this program to
 start the server. Please note that it may be necessary to increase the number 
 of open files per process (to avoid "Too many open files"-Error). 
@@ -53,9 +50,6 @@ alterations to application startup.
             await asyncio.Event().wait()
         asyncio.run(post_fork_main())
 
-.. testoutput::
-   :hide:
-
 This is another way to start multiple processes and have them all
 share the same port, although it has some limitations.  First, each
 child process will have its own ``IOLoop``, so it is important that
index ee33141ee0649f0c3000ebec16c0542dde92f59f..859ed6793008a4a95bda3126650b5c11c38b4c8e 100644 (file)
@@ -21,9 +21,6 @@ method:
             else:
                 self.write("Your cookie was set!")
 
-.. testoutput::
-   :hide:
-
 Cookies are not secure and can easily be modified by clients.  If you
 need to set cookies to, e.g., identify the currently logged in user,
 you need to sign your cookies to prevent forgery. Tornado supports
@@ -39,9 +36,6 @@ keyword arguments to your application:
         (r"/", MainHandler),
     ], cookie_secret="__TODO:_GENERATE_YOUR_OWN_RANDOM_VALUE_HERE__")
 
-.. testoutput::
-   :hide:
-
 Signed cookies contain the encoded value of the cookie in addition to a
 timestamp and an `HMAC <http://en.wikipedia.org/wiki/HMAC>`_ signature.
 If the cookie is old or if the signature doesn't match,
@@ -58,9 +52,6 @@ set. The secure version of the example above:
             else:
                 self.write("Your cookie was set!")
 
-.. testoutput::
-   :hide:
-
 Tornado's signed cookies guarantee integrity but not confidentiality.
 That is, the cookie cannot be modified but its contents can be seen by the
 user.  The ``cookie_secret`` is a symmetric key and must be kept secret --
@@ -129,9 +120,6 @@ specifying a nickname, which is then saved in a cookie:
         (r"/login", LoginHandler),
     ], cookie_secret="__TODO:_GENERATE_YOUR_OWN_RANDOM_VALUE_HERE__")
 
-.. testoutput::
-   :hide:
-
 You can require that the user be logged in using the `Python
 decorator <http://www.python.org/dev/peps/pep-0318/>`_
 `tornado.web.authenticated`. If a request goes to a method with this
@@ -156,9 +144,6 @@ rewritten:
         (r"/login", LoginHandler),
     ], **settings)
 
-.. testoutput::
-   :hide:
-
 If you decorate ``post()`` methods with the ``authenticated``
 decorator, and the user is not logged in, the server will send a
 ``403`` response.  The ``@authenticated`` decorator is simply
@@ -202,9 +187,6 @@ the Google credentials in a cookie for later access:
                     response_type='code',
                     extra_params={'approval_prompt': 'auto'})
 
-.. testoutput::
-   :hide:
-
 See the `tornado.auth` module documentation for more details.
 
 .. _xsrf:
@@ -237,9 +219,6 @@ include the application setting ``xsrf_cookies``:
         (r"/login", LoginHandler),
     ], **settings)
 
-.. testoutput::
-   :hide:
-
 If ``xsrf_cookies`` is set, the Tornado web application will set the
 ``_xsrf`` cookie for all users and reject all ``POST``, ``PUT``, and
 ``DELETE`` requests that do not contain a correct ``_xsrf`` value. If
index d120ea407ab7331d9a5849c0344dfda7a2dd8948..100ad6bb5f163a3710e9ead5bdb41385a1335922 100644 (file)
@@ -37,9 +37,6 @@ A minimal "hello world" example looks something like this:
     if __name__ == "__main__":
         asyncio.run(main())
 
-.. testoutput::
-   :hide:
-
 The ``main`` coroutine
 ~~~~~~~~~~~~~~~~~~~~~~
 
@@ -153,9 +150,6 @@ and `~.RequestHandler.get_body_argument`.
             self.set_header("Content-Type", "text/plain")
             self.write("You wrote " + self.get_body_argument("message"))
 
-.. testoutput::
-   :hide:
-
 Since the HTML form encoding is ambiguous as to whether an argument is
 a single value or a list with one element, `.RequestHandler` has
 distinct methods to allow the application to indicate whether or not
@@ -332,9 +326,6 @@ For example, here is a simple handler using a coroutine:
             self.write("Fetched " + str(len(json["entries"])) + " entries "
                        "from the FriendFeed API")
 
-.. testoutput::
-   :hide:
-
 For a more advanced asynchronous example, take a look at the `chat
 example application
 <https://github.com/tornadoweb/tornado/tree/stable/demos/chat>`_, which
index 7c5a8f4192dec4733ed2d5f15433c5fc33975358..db2ef453a133b729aa725180ab56ef9e563583a0 100644 (file)
@@ -62,9 +62,6 @@ directory as your Python file, you could render this template with:
             items = ["Item 1", "Item 2", "Item 3"]
             self.render("template.html", title="My title", items=items)
 
-.. testoutput::
-   :hide:
-
 Tornado templates support *control statements* and *expressions*.
 Control statements are surrounded by ``{%`` and ``%}``, e.g.
 ``{% if len(items) > 2 %}``. Expressions are surrounded by ``{{`` and
@@ -202,9 +199,6 @@ by overriding `.RequestHandler.get_user_locale`:
                 return None
             return self.current_user.prefs["locale"]
 
-.. testoutput::
-   :hide:
-
 If ``get_user_locale`` returns ``None``, we fall back on the
 ``Accept-Language`` header.
 
index d1edcc6550d62b6cf0b26388c053d41788d52b1e..2f115f576a626eb101e738e799da8643c1ce6442 100644 (file)
@@ -67,9 +67,6 @@ Example usage for Google OAuth:
                         response_type='code',
                         extra_params={'approval_prompt': 'auto'})
 
-.. testoutput::
-   :hide:
-
 """
 
 import base64
@@ -661,9 +658,6 @@ class OAuth2Mixin(object):
                         return
                     self.finish("Posted a message!")
 
-        .. testoutput::
-           :hide:
-
         .. versionadded:: 4.3
 
         .. versionchanged::: 6.0
@@ -721,9 +715,6 @@ class TwitterMixin(OAuthMixin):
                 else:
                     await self.authorize_redirect()
 
-    .. testoutput::
-       :hide:
-
     The user object returned by `~OAuthMixin.get_authenticated_user`
     includes the attributes ``username``, ``name``, ``access_token``,
     and all of the custom Twitter user attributes described at
@@ -805,9 +796,6 @@ class TwitterMixin(OAuthMixin):
                         return
                     self.finish("Posted a message!")
 
-        .. testoutput::
-           :hide:
-
         .. versionchanged:: 6.0
 
            The ``callback`` argument was removed. Use the returned
@@ -959,9 +947,6 @@ class GoogleOAuth2Mixin(OAuth2Mixin):
                                 response_type='code',
                                 extra_params={'approval_prompt': 'auto'})
 
-        .. testoutput::
-           :hide:
-
         .. versionchanged:: 6.0
 
            The ``callback`` argument was removed. Use the returned awaitable object instead.
@@ -1034,9 +1019,6 @@ class FacebookGraphMixin(OAuth2Mixin):
                         client_id=self.settings["facebook_api_key"],
                         extra_params={"scope": "user_posts"})
 
-        .. testoutput::
-           :hide:
-
         This method returns a dictionary which may contain the following fields:
 
         * ``access_token``, a string which may be passed to `facebook_request`
@@ -1151,9 +1133,6 @@ class FacebookGraphMixin(OAuth2Mixin):
                         return
                     self.finish("Posted a message!")
 
-        .. testoutput::
-           :hide:
-
         The given path is relative to ``self._FACEBOOK_BASE_URL``,
         by default "https://graph.facebook.com".
 
index 0e3c7a6fc2a06e3221f34ed54e8a0b26eea38781..7d87477486ff07f9ade4b1627584d0a5d9c81c75 100644 (file)
@@ -29,9 +29,6 @@ For example, here's a coroutine-based handler:
             do_something_with_response(response)
             self.render("template.html")
 
-.. testoutput::
-   :hide:
-
 Asynchronous functions in Tornado return an ``Awaitable`` or `.Future`;
 yielding this object returns its result.
 
@@ -51,9 +48,6 @@ of results will be returned when they are all finished:
         response3 = response_dict['response3']
         response4 = response_dict['response4']
 
-.. testoutput::
-   :hide:
-
 If ``tornado.platform.twisted`` is imported, it is also possible to
 yield Twisted's ``Deferred`` objects. See the `convert_yielded`
 function to extend this mechanism.
index 3fb1359aae174162e6d4aa8b12e877c0582d9e0e..5a880b0cdfae2c2ce5748dcc16acb29e0c06c583 100644 (file)
@@ -116,9 +116,6 @@ class IOLoop(Configurable):
         if __name__ == "__main__":
             asyncio.run(main())
 
-    .. testoutput::
-       :hide:
-
     Most applications should not attempt to construct an `IOLoop` directly,
     and instead initialize the `asyncio` event loop and use `IOLoop.current()`.
     In some cases, such as in test frameworks when initializing an `IOLoop`
index ee5775932e40abd115a79deb0c70cd95a80e9d84..e3956c4d1f6d1113c9e0a7343e396468b0fd7ea9 100644 (file)
@@ -1090,9 +1090,6 @@ class IOStream(BaseIOStream):
         if __name__ == '__main__':
             asyncio.run(main())
 
-    .. testoutput::
-       :hide:
-
     """
 
     def __init__(self, socket: socket.socket, *args: Any, **kwargs: Any) -> None:
index bc13c6f7da0be3bb3e26bb0c6c75a59918b06220..30cef30bd6d209615c24bf91a5d1de216ee8b751 100644 (file)
@@ -39,10 +39,6 @@ Here is a simple "Hello, world" example app:
     if __name__ == "__main__":
         asyncio.run(main())
 
-.. testoutput::
-   :hide:
-
-
 See the :doc:`guide` for additional information.
 
 Thread-safety notes
index 0127303076ace775960f2a2d775a870eda3c2a99..ad5db5590e297c1e96a5c34fa33fce1d9b78a659 100644 (file)
@@ -160,9 +160,6 @@ class WebSocketHandler(tornado.web.RequestHandler):
           def on_close(self):
               print("WebSocket closed")
 
-    .. testoutput::
-       :hide:
-
     WebSockets are not standard HTTP connections. The "handshake" is
     HTTP, but after the handshake, the protocol is
     message-based. Consequently, most of the Tornado HTTP facilities
diff --git a/tox.ini b/tox.ini
index a92c1c4c336e5110af72fe9774529a2914a50f6d..5c3f6c6bc5fbff3afb662906ed278544755c940b 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -103,9 +103,8 @@ commands =
     sphinx-build -q -E -n -W -b html . {envtmpdir}/html
     # Ensure that everything is either documented or ignored in conf.py
     sphinx-build -q -E -n -W -b coverage . {envtmpdir}/coverage
-    # Run the doctests. No -W for doctests because that disallows tests
-    # with empty output.
-    sphinx-build -q -E -n -b doctest . {envtmpdir}/doctest
+    # Run the doctests
+    sphinx-build -q -E -n -W -b doctest . {envtmpdir}/doctest
 
 [testenv:lint]
 commands =