-
Notifications
You must be signed in to change notification settings - Fork 99
Initial UITester API for writing toolkit agnostic tests #1107
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
Merged
Merged
Changes from 10 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
8bfd4d7
Initial UITester API
kitchoi d67958b
Add the missing __init__.py file
kitchoi 051e229
Add test requirement decorators
kitchoi 4629435
Add a sentence to the docstring
kitchoi 78faf30
Lots of renaming; move UIWrapper into its own module
kitchoi 33e4458
Differentiate the two register methods so if necessary, we can have a…
kitchoi 9f6bd10
Fix some docstring
kitchoi 0853e0e
Fix test requirements
kitchoi 3a2c210
A few more naming change in docstring
kitchoi fedfccd
Combine the registries into an object where composition occurs there
kitchoi 6eff638
Fix spelling and references to objects renamed/not-yet-added
kitchoi ddbb99a
Remove the description for nesting find_by_name (a future feature)
kitchoi 4a34dbb
One more docstring and spelling fix
kitchoi 909b684
Add copyright header
kitchoi 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
Empty file.
Empty file.
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,28 @@ | ||
| # Copyright (c) 2005-2020, Enthought, Inc. | ||
| # All rights reserved. | ||
| # | ||
| # This software is provided without warranty under the terms of the BSD | ||
| # license included in LICENSE.txt and may be redistributed only | ||
| # under the conditions described in the aforementioned license. The license | ||
| # is also available online at http://www.enthought.com/licenses/BSD.txt | ||
| # | ||
| # Thanks for using Enthought open source! | ||
| # | ||
|
|
||
| """ This module defines interaction objects that can be passed to | ||
| ``UIWrapper.perform`` where the actions represent 'commands'. | ||
|
|
||
| Implementations for these actions are expected to produce the | ||
| documented side effects without returning any values. | ||
| """ | ||
|
|
||
|
|
||
| class MouseClick: | ||
| """ An object representing the user clicking a mouse button. | ||
| Currently the left mouse button is assumed. | ||
|
|
||
| In most circumstances, a widget can still be clicked on even if it is | ||
| disabled. Therefore unlike key events, if the widget is disabled, | ||
| implementations should not raise an exception. | ||
| """ | ||
| pass |
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,61 @@ | ||
| # Copyright (c) 2005-2020, Enthought, Inc. | ||
| # All rights reserved. | ||
| # | ||
| # This software is provided without warranty under the terms of the BSD | ||
| # license included in LICENSE.txt and may be redistributed only | ||
| # under the conditions described in the aforementioned license. The license | ||
| # is also available online at http://www.enthought.com/licenses/BSD.txt | ||
| # | ||
| # Thanks for using Enthought open source! | ||
| # | ||
|
|
||
|
|
||
| class TesterError(Exception): | ||
| """ Custom exception for UITester/UIWrapper. """ | ||
| pass | ||
|
|
||
|
|
||
| class InteractionNotSupported(TesterError): | ||
| """ Raised when an interaction is not supported by a wrapper. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| target_class : subclass of type | ||
| The type of a UI target being operated on. | ||
| interaction_class : subclass of type | ||
| Any class for the interaction. | ||
| supported : list of types | ||
| List of supported interaction types. | ||
| """ | ||
|
|
||
| def __init__(self, target_class, interaction_class, supported): | ||
| self.target_class = target_class | ||
| self.interaction_class = interaction_class | ||
| self.supported = supported | ||
|
|
||
| def __str__(self): | ||
| return ( | ||
| "No handler is found for target {!r} with interaction {!r}. " | ||
| "Supported these: {!r}".format( | ||
| self.target_class, self.interaction_class, self.supported | ||
| ) | ||
| ) | ||
|
|
||
|
|
||
| class LocationNotSupported(TesterError): | ||
| """ Raised when attempt to resolve a location on a UI fails | ||
| because the location type is not supported. | ||
| """ | ||
|
|
||
| def __init__(self, target_class, locator_class, supported): | ||
| self.target_class = target_class | ||
| self.locator_class = locator_class | ||
| self.supported = supported | ||
|
|
||
| def __str__(self): | ||
| return ( | ||
| "Location {!r} is not supported for {!r}. " | ||
| "Supported these: {!r}".format( | ||
| self.locator_class, self.target_class, self.supported | ||
| ) | ||
| ) |
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,26 @@ | ||
| """ This module defines objects for locating nested UI targets, to be | ||
| used with ``UIWrapper.locate``. | ||
|
|
||
| Implementations for these actions are expected to return a value which is | ||
| a UI target where further location resolution or user interaction can be | ||
| applied. | ||
| """ | ||
|
|
||
|
|
||
| class NestedUI: | ||
| """ A locator for locating a nested ``traitsui.ui.UI`` object assuming | ||
| there is only one. If there are multiple, more location information | ||
| needs to have been provided already. | ||
| """ | ||
| pass | ||
|
|
||
|
|
||
| class TargetByName: | ||
| """ A locator for locating the next UI target using a name. | ||
|
|
||
| Attributes | ||
| ---------- | ||
| name : str | ||
| """ | ||
| def __init__(self, name): | ||
| self.name = name | ||
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,29 @@ | ||
| # Copyright (c) 2005-2020, Enthought, Inc. | ||
| # All rights reserved. | ||
| # | ||
| # This software is provided without warranty under the terms of the BSD | ||
| # license included in LICENSE.txt and may be redistributed only | ||
| # under the conditions described in the aforementioned license. The license | ||
| # is also available online at http://www.enthought.com/licenses/BSD.txt | ||
| # | ||
| # Thanks for using Enthought open source! | ||
| # | ||
|
|
||
| """ This module defines interaction objects that can be passed to | ||
| ``UIWrapper.inspect`` where the actions represent 'queries'. | ||
|
|
||
| Implementations for these actions are expected to return value(s), ideally | ||
| without incurring side-effects. | ||
| """ | ||
|
|
||
|
|
||
| class DisplayedText: | ||
| """ An object representing an interaction to obtain the displayed (echoed) | ||
| plain text. | ||
|
|
||
| E.g. For a textbox using a password styling, the displayed text should | ||
| be a string of platform-dependent password mask characters. | ||
|
|
||
| Implementations should return a ``str``. | ||
| """ | ||
| pass |
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.
Uh oh!
There was an error while loading. Please reload this page.