File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed
Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -425,20 +425,26 @@ Improved error messages
425425 method names from other languages (JavaScript, Java, Ruby, C#) and suggests
426426 the Python equivalent:
427427
428- .. code-block :: pycon
428+ .. doctest ::
429429
430- >>> [1, 2, 3].push(4)
430+ >>> [1 , 2 , 3 ].push(4 ) # doctest: +ELLIPSIS
431+ Traceback (most recent call last):
432+ ...
431433 AttributeError: 'list' object has no attribute 'push'. Did you mean '.append'?
432434
433- >>> 'hello'.toUpperCase()
435+ >>> ' hello' .toUpperCase() # doctest: +ELLIPSIS
436+ Traceback (most recent call last):
437+ ...
434438 AttributeError: 'str' object has no attribute 'toUpperCase'. Did you mean '.upper'?
435439
436440 When the Python equivalent is a language construct rather than a method,
437441 the hint describes the construct directly:
438442
439- .. code-block :: pycon
443+ .. doctest ::
440444
441- >>> {}.put("a", 1)
445+ >>> {}.put(" a" , 1 ) # doctest: +ELLIPSIS
446+ Traceback (most recent call last):
447+ ...
442448 AttributeError: 'dict' object has no attribute 'put'. Use dict[key] = value for item assignment
443449
444450 (Contributed by Matt Van Horn in :gh: `146406 `.)
You can’t perform that action at this time.
0 commit comments