Repository navigation
Leaving the inspect dialog resumes the interrupted evaluation #2123
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| # -*- coding: utf-8 -*- | ||
| """ | ||
| The interrupt menu's "inspect" dialog evaluates its input with the | ||
| evaluation that was interrupted. Leaving the dialog (Ctrl-D) must give that | ||
| evaluation back as it was, so that it goes on; it used to stop at its next | ||
| check with "Timeout reached" and give $Aborted. | ||
| """ | ||
|
|
||
| import pytest | ||
|
|
||
| from mathics.core.definitions import Definitions | ||
| from mathics.core.evaluation import Evaluation | ||
| from mathics.core.load_builtin import import_and_load_builtins | ||
| from mathics.interrupt import inspect_eval_loop | ||
| from mathics.repl import TerminalShell | ||
|
|
||
|
|
||
| def test_leaving_the_dialog_resumes_the_interrupted_evaluation(capsys): | ||
| import_and_load_builtins() | ||
| definitions = Definitions(add_builtin=True) | ||
| shell = TerminalShell( | ||
| definitions, "NoColor", want_readline=False, want_completion=False, autoload=False | ||
| ) | ||
| script = ["1+1", EOFError()] | ||
|
|
||
| def read_line(prompt): | ||
| step = script.pop(0) | ||
| if isinstance(step, BaseException): | ||
| raise step | ||
| return step | ||
|
|
||
| shell.read_line = read_line | ||
| evaluation = Evaluation(definitions) | ||
| evaluation.shell = shell | ||
| # The interrupted evaluation, as it is while it runs. | ||
| evaluation.stopped = False | ||
| evaluation.timeout = False | ||
| evaluation.deadline = None | ||
| evaluation.recursion_depth = 7 | ||
| pending = evaluation.out | ||
|
|
||
| with pytest.raises(EOFError): # Ctrl-D: the menu takes it as "leave the dialog" | ||
| inspect_eval_loop(evaluation) | ||
|
|
||
| assert "= 2" in capsys.readouterr().out, "the dialog did not evaluate 1+1" | ||
| assert evaluation.stopped is False | ||
| assert evaluation.recursion_depth == 7 | ||
| assert evaluation.out is pending | ||
| evaluation.check_stopped() # must not raise TimeoutInterrupt |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Maybe this should be an Enumeration
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.
The sense I am getting is that AI is good with several things, but it can use or tolerate older forms of Python, and also does not pick up that well on the existing style and practice of existing code (unless explicitly directed to). I suspect this is also why we see so many isort/black failures initially as well.