-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
PR: Add an option to show/hide line numbers to History #5363
Conversation
Hello @csabella! Thanks for updating the PR.
Comment last updated on October 04, 2017 at 20:26 Hours UTC |
I added some tests for history.py, but not complete coverage in case the tests weren't the way you would like them. I tried to follow existing patterns, but I didn't do anything with simulating user activity via qtbot. Please let me know if the tests are OK or if they should have been done differently so that I can make sure to apply the correct style if I write more of them. Thanks! |
spyder/plugins/tests/test_history.py
Outdated
|
||
#============================================================================== | ||
# Constants | ||
#============================================================================== |
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.
Please remove this block comment if it's not needed.
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.
Done.
#============================================================================== | ||
# Tests | ||
#============================================================================== | ||
|
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.
Remove this blank line
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.
Done.
|
||
|
||
@pytest.fixture | ||
def historylog_with_tab(historylog, mocker, monkeypatch): |
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.
Please add a docstring to describe what this fixture is about.
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.
Done.
# Tests | ||
#============================================================================== | ||
|
||
def test_init(historylog): |
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.
Please add a short docstring to all tests to describe what each one is testing.
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.
Done. My tests matched to the methods, so I wasn't quite sure what to write. If it's too redundant, I can change it.
This is a very good addition @csabella, specially because of all the tests you added! Thanks for taking the time to create them. |
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.
I tested locally and works as expected 😄
Thanks for adding all those tests 🙇
I leave a comment about moving testing logic out of the plugin
spyder/plugins/history.py
Outdated
@@ -111,7 +116,8 @@ def __init__(self, parent): | |||
# Find/replace widget | |||
self.find_widget = FindReplace(self) | |||
self.find_widget.hide() | |||
self.register_widget_shortcuts(self.find_widget) | |||
if not self.testing: | |||
self.register_widget_shortcuts(self.find_widget) |
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.
I think It's better to monkeypath this in the test fixture instead of adding test logic to the plugin:
@pytest.fixture
def historylog(qtbot, monkeypatch):
monkeypatch.setattr(
'spyder.plugins.history.HistoryLog.register_widget_shortcuts',
lambda *args: None)
historylog = history.HistoryLog(None, testing=True)
[...]
Please remove the testing
arg, and monkeypath the fixture
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.
Thanks! I had added testing
based on test_ipythonconsole
, but I agree that the monkeypatch is better.
Thanks @csabella, this is going in! |
Thank you! |
Fixes #970.