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
turtledemo modules imported by test___all__ cause side effects or failures #66081
Comments
Although the turtledemo modules are not run directly during by "make test" or by "python -m test -uall", they are currently being inadvertently imported by test___all__. This can lead to test failures and side effects because some of the turtledemo modules execute code on import, rather than only when being run via calls to their main() functions. A quick glance shows problems with the following demos: clock (calls mode("logo") which causes a window to appear), colormixer (which unconditionally calls sys.setrecursionlimit()), and two_canvases (which is not structured using functions at all). Depending on how tests are run, these problems can cause serious side effects. At a minimum,
It would also be nice to make the demos better citizens: |
Agreed. In general, the test suite shouldn't open any GUI windows except if the "gui" resource is enabled (which isn't the default). |
re 2: If the mode call is needed, it is a bug that it is not main() as another demo could change it. re 3: ditto, though much less likely. re 4: As mentioned in bpo-14117, two_canvases is buggy in that the code is not displayed. I added a comment in the file about things that don't work. A main function is the next thing to try anyway. If no one does the turtledemo changes, I probably will soon. |
I am working on the turtle demos now. Victor gave more info in bpo-21884. I was partly wrong in my comments. turtledemo uses reload to re-initialize demos when one switches between them. I am tempted to remove this as part of discouraging side-effects on import. It is not a good example to be followed. |
New changeset c173a34f20c0 by Terry Jan Reedy in branch '2.7': New changeset fcfa9c5a00fd by Terry Jan Reedy in branch '3.4': |
|
The __all__ test now passes on Snow Leapard. |
I opened bpo-22051 about removing reload to force better code. Since the tests are passing and I think the demo modules should be minimally tested by importing, and no one has said otherwise since the fix, I am closing this. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: