File tree Expand file tree Collapse file tree 1 file changed +17
-5
lines changed
Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -2661,15 +2661,27 @@ will be pulled from the default value.
26612661 *not * a leap year. Always add a default leap year to partial date strings
26622662 before parsing.
26632663
2664+
2665+ .. testsetup ::
2666+
2667+ # doctest seems to turn the warning into an error which makes it
2668+ # show up and require matching and prevents the actual interesting
2669+ # exception from being raised.
2670+ # Manually apply the catch_warnings context manager
2671+ import warnings
2672+ catch_warnings = warnings.catch_warnings()
2673+ catch_warnings.__enter__()
2674+ warnings.simplefilter("ignore")
2675+
2676+ .. testcleanup ::
2677+
2678+ catch_warnings.__exit__()
2679+
26642680.. doctest ::
26652681
26662682 >>> from datetime import datetime
2667- >>> import warnings
26682683 >>> value = " 2/29"
2669- >>> with warnings.catch_warnings():
2670- ... warnings.simplefilter(" ignore" )
2671- ... datetime.strptime(value, " %m/%d " )
2672- ...
2684+ >>> datetime.strptime(value, " %m/%d " )
26732685 Traceback (most recent call last):
26742686 ...
26752687 ValueError: day 29 must be in range 1..28 for month 2 in year 1900
You can’t perform that action at this time.
0 commit comments