diff options
author | Marco Buttu <marco.buttu@gmail.com> | 2017-03-18 16:59:33 (GMT) |
---|---|---|
committer | Berker Peksag <berker.peksag@gmail.com> | 2017-03-18 16:59:33 (GMT) |
commit | 909a6f626ff343937cd3f06fda996870e7890724 (patch) | |
tree | 023cea76fe93c42b8a01a843e450c26b05cd92db | |
parent | 993d4b3440f2282976901ce66879037c4443868a (diff) | |
download | cpython-909a6f626ff343937cd3f06fda996870e7890724.zip cpython-909a6f626ff343937cd3f06fda996870e7890724.tar.gz cpython-909a6f626ff343937cd3f06fda996870e7890724.tar.bz2 |
bpo-27200: Fix doctests in programming.rst and datetime.rst (#401)
-rw-r--r-- | Doc/conf.py | 1 | ||||
-rw-r--r-- | Doc/faq/programming.rst | 4 | ||||
-rw-r--r-- | Doc/includes/tzinfo_examples.py (renamed from Doc/includes/tzinfo-examples.py) | 0 | ||||
-rw-r--r-- | Doc/library/datetime.rst | 10 |
4 files changed, 10 insertions, 5 deletions
diff --git a/Doc/conf.py b/Doc/conf.py index 18aebb6..c1c2472 100644 --- a/Doc/conf.py +++ b/Doc/conf.py @@ -8,6 +8,7 @@ import sys, os, time sys.path.append(os.path.abspath('tools/extensions')) +sys.path.append(os.path.abspath('includes')) # General configuration # --------------------- diff --git a/Doc/faq/programming.rst b/Doc/faq/programming.rst index 9c5e20d..d9bdb21 100644 --- a/Doc/faq/programming.rst +++ b/Doc/faq/programming.rst @@ -1849,7 +1849,7 @@ containing statements like :: will continue to work with the old version of the imported objects. If the module contains class definitions, existing class instances will *not* be updated to use the new class definition. This can result in the following -paradoxical behaviour: +paradoxical behaviour:: >>> import importlib >>> import cls @@ -1860,7 +1860,7 @@ paradoxical behaviour: False The nature of the problem is made clear if you print out the "identity" of the -class objects: +class objects:: >>> hex(id(c.__class__)) '0x7352a0' diff --git a/Doc/includes/tzinfo-examples.py b/Doc/includes/tzinfo_examples.py index ae5a509..ae5a509 100644 --- a/Doc/includes/tzinfo-examples.py +++ b/Doc/includes/tzinfo_examples.py diff --git a/Doc/library/datetime.rst b/Doc/library/datetime.rst index c931855..700a19d 100644 --- a/Doc/library/datetime.rst +++ b/Doc/library/datetime.rst @@ -1221,7 +1221,7 @@ Instance methods: >>> from datetime import datetime - >>> datetime.now().isoformat(timespec='minutes') + >>> datetime.now().isoformat(timespec='minutes') # doctest: +SKIP '2002-12-25T00:00' >>> dt = datetime(2015, 1, 1, 12, 30, 59, 0) >>> dt.isoformat(timespec='microseconds') @@ -1781,9 +1781,11 @@ There is one more :class:`tzinfo` method that a subclass may wish to override: else: return dt -Example :class:`tzinfo` classes: +In the following :download:`tzinfo_examples.py +<../includes/tzinfo_examples.py>` file there are some examples of +:class:`tzinfo` classes: -.. literalinclude:: ../includes/tzinfo-examples.py +.. literalinclude:: ../includes/tzinfo_examples.py Note that there are unavoidable subtleties twice per year in a :class:`tzinfo` subclass accounting for both standard and daylight time, at the DST transition @@ -1804,6 +1806,8 @@ When DST starts (the "start" line), the local wall clock leaps from 1:59 to ``astimezone(Eastern)`` won't deliver a result with ``hour == 2`` on the day DST begins. For example, at the Spring forward transition of 2016, we get + >>> from datetime import datetime, timezone + >>> from tzinfo_examples import HOUR, Eastern >>> u0 = datetime(2016, 3, 13, 5, tzinfo=timezone.utc) >>> for i in range(4): ... u = u0 + i*HOUR |