-
Notifications
You must be signed in to change notification settings - Fork 95
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
Support testing with simple FileEditor (without dialog) #1571
Conversation
Note: One can apply more or less the same change for the simple DirectoryEditor (not covered here). |
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.
LGTM
Just a couple comments about skipping tests on wx
traitsui/examples/demo/Standard_Editors/tests/test_FileEditor_demo.py
Outdated
Show resolved
Hide resolved
|
||
class TestFileEditorDemo(unittest.TestCase): | ||
|
||
def test_run_demo(self): |
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.
You say in the PR description: "The test for the FileEditor demo fails on wx due to #752". Should this have an @requires_toolkit(['ToolkitName.qt'])
in that case?
/ a comment regarding the failure being linked to having a custom editor included in the demo?
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.
Good point. Yes I should add the decorator.
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.
Yes I should add the decorator.
On second thought, this is a demo test so I'd want to avoid importing anything from traitsui.tests._tools
.
Will go with a comment instead :/
This PR adds testing support for the simple FileEditor via its text widget.
DisplayedText
,KeyClick
,KeySequence
can now be used for testing with a simple FileEditorThis is motivated by an observation of a similar extension being made in a downstream project. One will extend using the
_file_name
attribute on the editor, acknowledging that such extension relies on implementation details of the editor. If the testing support is implemented in traitsui, then the support can be maintained along with those implementation details.In the context of testing an application, it is often sufficient to set a file path via the text widget instead of via the file modal dialog.
This goes some way towards solving #1339. It also extends TraitsUI's own test coverage for the simple FileEditor.
Observations:
entries
trait on the FileEditor factory is only supported by wx. If set on wx, the simple FileEditor will have a combo box instead of a text widget. The simple FileEditor on wx is effectively two editors in one. That branch is not tested here.