diff options
| author | Sergey Shepelev <temotor@gmail.com> | 2013-10-07 16:48:34 +0400 |
|---|---|---|
| committer | Sergey Shepelev <temotor@gmail.com> | 2013-12-03 22:36:29 +0400 |
| commit | d2bbbd79d3f903fbff59f09467af681d5b9282cf (patch) | |
| tree | 6a6da9b62894d62fdaa1050acbd39c46e710b9e8 /doc | |
| parent | 35f600600c59c295fab0131c7bc0032e28b70045 (diff) | |
| download | eventlet-d2bbbd79d3f903fbff59f09467af681d5b9282cf.tar.gz | |
python3 compat: remove lots of Python 2.5 and earlier dependent code; use print() function syntax
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/modules/timeout.rst | 27 | ||||
| -rw-r--r-- | doc/testing.rst | 14 |
2 files changed, 19 insertions, 22 deletions
diff --git a/doc/modules/timeout.rst b/doc/modules/timeout.rst index 6a6ce98..ecd950b 100644 --- a/doc/modules/timeout.rst +++ b/doc/modules/timeout.rst @@ -11,7 +11,7 @@ finally: timeout.cancel() - When *exception* is omitted or ``None``, the :class:`Timeout` instance + When *exception* is omitted or ``None``, the :class:`Timeout` instance itself is raised: >>> Timeout(0.1) @@ -20,16 +20,15 @@ ... Timeout: 0.1 seconds - In Python 2.5 and newer, you can use the ``with`` statement for additional - convenience:: + You can use the ``with`` statement for additional convenience:: with Timeout(seconds, exception) as timeout: pass # ... code block ... - This is equivalent to the try/finally block in the first example. - - There is an additional feature when using the ``with`` statement: if - *exception* is ``False``, the timeout is still raised, but the with + This is equivalent to the try/finally block in the first example. + + There is an additional feature when using the ``with`` statement: if + *exception* is ``False``, the timeout is still raised, but the with statement suppresses it, so the code outside the with-block won't see it:: data = None @@ -39,12 +38,12 @@ ... # 5 seconds passed without reading a line else: ... # a line was read within 5 seconds - - As a very special case, if *seconds* is None, the timer is not scheduled, + + As a very special case, if *seconds* is None, the timer is not scheduled, and is only useful if you're planning to raise it directly. There are two Timeout caveats to be aware of: - + * If the code block in the try/finally or with-block never cooperatively yields, the timeout cannot be raised. In Eventlet, this should rarely be a problem, but be aware that you cannot time out CPU-only operations with this class. * If the code block catches and doesn't re-raise :class:`BaseException` (for example, with ``except:``), then it will catch the Timeout exception, and might not abort as intended. @@ -58,7 +57,7 @@ except Timeout, t: if t is not timeout: raise # not my timeout - + .. automethod:: cancel .. autoattribute:: pending @@ -76,7 +75,7 @@ :param \*\*kwds: keyword arguments to pass to *func* :param timeout_value: value to return if timeout occurs (by default raises :class:`Timeout`) - + :rtype: Value returned by *func* if *func* returns before *seconds*, else *timeout_value* if provided, else raises :class:`Timeout`. @@ -88,6 +87,6 @@ data = with_timeout(30, urllib2.open, 'http://www.google.com/', timeout_value="") - Here *data* is either the result of the ``get()`` call, or the empty string - if it took too long to return. Any exception raised by the ``get()`` call + Here *data* is either the result of the ``get()`` call, or the empty string + if it took too long to return. Any exception raised by the ``get()`` call is passed through to the caller. diff --git a/doc/testing.rst b/doc/testing.rst index d63d8d2..1e7a887 100644 --- a/doc/testing.rst +++ b/doc/testing.rst @@ -6,7 +6,7 @@ Eventlet is tested using `Nose <http://somethingaboutorange.com/mrl/projects/nos .. code-block:: sh $ python setup.py test - + If you want access to all the nose plugins via command line, you can run: .. code-block:: sh @@ -23,8 +23,6 @@ That's it! The output from running nose is the same as unittest's output, if th Many tests are skipped based on environmental factors; for example, it makes no sense to test Twisted-specific functionality when Twisted is not installed. These are printed as S's during execution, and in the summary printed after the tests run it will tell you how many were skipped. -.. note:: If running Python version 2.4, use this command instead: ``python tests/nosewrapper.py``. There are several tests which make use of the `with` statement and therefore will cause nose grief when it tries to import them; nosewrapper.py excludes these tests so they are skipped. - Doctests -------- @@ -33,7 +31,7 @@ To run the doctests included in many of the eventlet modules, use this command: .. code-block :: sh $ nosetests --with-doctest eventlet/*.py - + Currently there are 16 doctests. Standard Library Tests @@ -46,7 +44,7 @@ There's a convenience module called all.py designed to handle the impedance mism .. code-block:: sh $ nosetests tests/stdlib/all.py - + That will run all the tests, though the output will be a little weird because it will look like Nose is running about 20 tests, each of which consists of a bunch of sub-tests. Not all test modules are present in all versions of Python, so there will be an occasional printout of "Not importing %s, it doesn't exist in this installation/version of Python". If you see "Ran 0 tests in 0.001s", it means that your Python installation lacks its own tests. This is usually the case for Linux distributions. One way to get the missing tests is to download a source tarball (of the same version you have installed on your system!) and copy its Lib/test directory into the correct place on your PYTHONPATH. @@ -75,7 +73,7 @@ If you are writing a test that involves a client connecting to a spawned server, server_sock = eventlet.listener(('127.0.0.1', 0)) client_sock = eventlet.connect(('localhost', server_sock.getsockname()[1])) - + Coverage -------- @@ -84,7 +82,7 @@ Coverage.py is an awesome tool for evaluating how much code was exercised by uni .. code-block:: sh nosetests --with-coverage --cover-package=eventlet - + After running the tests to completion, this will emit a huge wodge of module names and line numbers. For some reason, the ``--cover-inclusive`` option breaks everything rather than serving its purpose of limiting the coverage to the local files, so don't use that. The html option is quite useful because it generates nicely-formatted HTML that are much easier to read than line-number soup. Here's a command that generates the annotation, dumping the html files into a directory called "cover": @@ -92,5 +90,5 @@ The html option is quite useful because it generates nicely-formatted HTML that .. code-block:: sh coverage html -d cover --omit='tempmod,<console>,tests' - + (``tempmod`` and ``console`` are omitted because they gets thrown away at the completion of their unit tests and coverage.py isn't smart enough to detect this.) |
