Skip to content

Commit 909a6f6

Browse files
marco-buttuberkerpeksag
authored andcommitted
bpo-27200: Fix doctests in programming.rst and datetime.rst (#401)
1 parent 993d4b3 commit 909a6f6

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

Doc/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import sys, os, time
1010
sys.path.append(os.path.abspath('tools/extensions'))
11+
sys.path.append(os.path.abspath('includes'))
1112

1213
# General configuration
1314
# ---------------------

Doc/faq/programming.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1849,7 +1849,7 @@ containing statements like ::
18491849
will continue to work with the old version of the imported objects. If the
18501850
module contains class definitions, existing class instances will *not* be
18511851
updated to use the new class definition. This can result in the following
1852-
paradoxical behaviour:
1852+
paradoxical behaviour::
18531853

18541854
>>> import importlib
18551855
>>> import cls
@@ -1860,7 +1860,7 @@ paradoxical behaviour:
18601860
False
18611861

18621862
The nature of the problem is made clear if you print out the "identity" of the
1863-
class objects:
1863+
class objects::
18641864

18651865
>>> hex(id(c.__class__))
18661866
'0x7352a0'
File renamed without changes.

Doc/library/datetime.rst

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,7 +1221,7 @@ Instance methods:
12211221

12221222

12231223
>>> from datetime import datetime
1224-
>>> datetime.now().isoformat(timespec='minutes')
1224+
>>> datetime.now().isoformat(timespec='minutes') # doctest: +SKIP
12251225
'2002-12-25T00:00'
12261226
>>> dt = datetime(2015, 1, 1, 12, 30, 59, 0)
12271227
>>> dt.isoformat(timespec='microseconds')
@@ -1781,9 +1781,11 @@ There is one more :class:`tzinfo` method that a subclass may wish to override:
17811781
else:
17821782
return dt
17831783

1784-
Example :class:`tzinfo` classes:
1784+
In the following :download:`tzinfo_examples.py
1785+
<../includes/tzinfo_examples.py>` file there are some examples of
1786+
:class:`tzinfo` classes:
17851787

1786-
.. literalinclude:: ../includes/tzinfo-examples.py
1788+
.. literalinclude:: ../includes/tzinfo_examples.py
17871789

17881790
Note that there are unavoidable subtleties twice per year in a :class:`tzinfo`
17891791
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
18041806
``astimezone(Eastern)`` won't deliver a result with ``hour == 2`` on the day DST
18051807
begins. For example, at the Spring forward transition of 2016, we get
18061808

1809+
>>> from datetime import datetime, timezone
1810+
>>> from tzinfo_examples import HOUR, Eastern
18071811
>>> u0 = datetime(2016, 3, 13, 5, tzinfo=timezone.utc)
18081812
>>> for i in range(4):
18091813
... u = u0 + i*HOUR

0 commit comments

Comments
 (0)