-
-
Notifications
You must be signed in to change notification settings - Fork 35.3k
gh-111735: Fix turtle.rst doctests when tkinter is not present
#111736
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ | |
| **Source code:** :source:`Lib/turtle.py` | ||
|
|
||
| .. testsetup:: default | ||
| :skipif: _tkinter is None | ||
|
|
||
| from turtle import * | ||
| turtle = Turtle() | ||
|
|
@@ -471,6 +472,7 @@ Turtle motion | |
| turtle is headed. Do not change the turtle's heading. | ||
|
|
||
| .. doctest:: | ||
| :skipif: _tkinter is None | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since elsewhere the directly seems to apply to multiple test without intervening text (correct?), I believe addition makes the directive on 380-1 obsolete. |
||
| :hide: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does doctest really fail on blank output? Or what does :hide: do? |
||
|
|
||
| >>> turtle.goto(0, 0) | ||
|
|
@@ -809,6 +811,7 @@ Turtle motion | |
| last *n* stamps. | ||
|
|
||
| .. doctest:: | ||
| :skipif: _tkinter is None | ||
|
|
||
| >>> for i in range(8): | ||
| ... unused_stamp_id = turtle.stamp() | ||
|
|
@@ -1336,8 +1339,11 @@ More drawing control | |
| font. If *move* is true, the pen is moved to the bottom-right corner of the | ||
| text. By default, *move* is ``False``. | ||
|
|
||
| >>> turtle.write("Home = ", True, align="center") | ||
| >>> turtle.write((0,0), True) | ||
| .. doctest:: | ||
| :skipif: _tkinter is None | ||
|
|
||
| >>> turtle.write("Home = ", True, align="center") | ||
| >>> turtle.write((0,0), True) | ||
|
|
||
|
|
||
| Turtle state | ||
|
|
@@ -1374,12 +1380,15 @@ Visibility | |
|
|
||
| Return ``True`` if the Turtle is shown, ``False`` if it's hidden. | ||
|
|
||
| >>> turtle.hideturtle() | ||
| >>> turtle.isvisible() | ||
| False | ||
| >>> turtle.showturtle() | ||
| >>> turtle.isvisible() | ||
| True | ||
| .. doctest:: | ||
| :skipif: _tkinter is None | ||
|
|
||
| >>> turtle.hideturtle() | ||
| >>> turtle.isvisible() | ||
| False | ||
| >>> turtle.showturtle() | ||
| >>> turtle.isvisible() | ||
| True | ||
|
|
||
|
|
||
| Appearance | ||
|
|
@@ -1822,7 +1831,10 @@ Window control | |
| Set background image or return name of current backgroundimage. If *picname* | ||
| is a filename, set the corresponding image as background. If *picname* is | ||
| ``"nopic"``, delete background image, if present. If *picname* is ``None``, | ||
| return the filename of the current backgroundimage. :: | ||
| return the filename of the current backgroundimage. | ||
|
|
||
| .. doctest:: | ||
| :skipif: True | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we should just not add the
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I remove this line, there will be an error locally. I don't know why, I have no idea how to debug this kind of problems.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh. That's weird :( |
||
|
|
||
| >>> screen.bgpic() | ||
| 'nopic' | ||
|
|
@@ -1873,6 +1885,9 @@ Window control | |
| method, one can make visible those parts of a drawing which were outside the | ||
| canvas before. | ||
|
|
||
| .. doctest:: | ||
| :skipif: _tkinter is None | ||
|
|
||
| >>> screen.screensize() | ||
| (400, 300) | ||
| >>> screen.screensize(2000,1500) | ||
|
|
@@ -2089,7 +2104,10 @@ Input methods | |
| Pop up a dialog window for input of a string. Parameter title is | ||
| the title of the dialog window, prompt is a text mostly describing | ||
| what information to input. | ||
| Return the string input. If the dialog is canceled, return ``None``. :: | ||
| Return the string input. If the dialog is canceled, return ``None``. | ||
|
|
||
| .. doctest:: | ||
| :skipif: True | ||
|
|
||
| >>> screen.textinput("NIM", "Name of first player:") | ||
|
|
||
|
|
@@ -2109,7 +2127,10 @@ Input methods | |
| The number input must be in the range minval .. maxval if these are | ||
| given. If not, a hint is issued and the dialog remains open for | ||
| correction. | ||
| Return the number input. If the dialog is canceled, return ``None``. :: | ||
| Return the number input. If the dialog is canceled, return ``None``. | ||
|
|
||
| .. doctest:: | ||
| :skipif: True | ||
|
|
||
| >>> screen.numinput("Poker", "Your stakes:", 1000, minval=10, maxval=10000) | ||
|
|
||
|
|
@@ -2197,9 +2218,12 @@ Settings and special methods | |
| There are three different ways to call this function: | ||
|
|
||
| (1) *name* is the name of a gif-file and *shape* is ``None``: Install the | ||
| corresponding image shape. :: | ||
| corresponding image shape. | ||
|
|
||
| .. doctest:: | ||
| :skipif: True | ||
|
|
||
| >>> screen.register_shape("turtle.gif") | ||
| >>> screen.register_shape("turtle.gif") | ||
|
|
||
| .. note:: | ||
| Image shapes *do not* rotate when turning the turtle, so they do not | ||
|
|
@@ -2233,15 +2257,21 @@ Settings and special methods | |
|
|
||
| .. function:: window_height() | ||
|
|
||
| Return the height of the turtle window. :: | ||
| Return the height of the turtle window. | ||
|
|
||
| .. doctest:: | ||
| :skipif: True | ||
|
|
||
| >>> screen.window_height() | ||
| 480 | ||
|
|
||
|
|
||
| .. function:: window_width() | ||
|
|
||
| Return the width of the turtle window. :: | ||
| Return the width of the turtle window. | ||
|
|
||
| .. doctest:: | ||
| :skipif: True | ||
|
|
||
| >>> screen.window_width() | ||
| 640 | ||
|
|
@@ -2448,7 +2478,10 @@ facilities: | |
| - When using IDLE, tooltips show the signatures and first lines of the | ||
| docstrings of typed in function-/method calls. | ||
|
|
||
| - Calling :func:`help` on methods or functions displays the docstrings:: | ||
| - Calling :func:`help` on methods or functions displays the docstrings: | ||
|
|
||
| .. doctest:: | ||
| :skipif: True | ||
|
|
||
| >>> help(Screen.bgcolor) | ||
| Help on method bgcolor in module turtle: | ||
|
|
@@ -2480,7 +2513,10 @@ facilities: | |
| >>> turtle.penup() | ||
|
|
||
| - The docstrings of the functions which are derived from methods have a modified | ||
| form:: | ||
| form: | ||
|
|
||
| .. doctest:: | ||
| :skipif: True | ||
|
|
||
| >>> help(bgcolor) | ||
| Help on function bgcolor in module turtle: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the directive is only 'seen' by sphinx, doctest.testfile fails miserably on this file (326 of 337). It seems that this file was never meant to be doctested. Can one make the directive global instead of local.
If the 2 lines were given as examples of how to minimally start (>>> import, >>> turtle =) as would seem sensible, then I believe tests would run. But I understand that you are not intending to edit content.