Skip to content
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

Prevent test_enum failures if traitsui or GUI toolkit are not installed #1349

Merged
merged 2 commits into from
Nov 16, 2020

Conversation

aaronayres35
Copy link
Contributor

Fixes #1266

In this PR I first simply broke pyface.toolkit.toolkit_object up into from pyface.toolkit import toolkit_object and then called toolkit_object. This fixed the AttributeError: module 'pyface' has no attribute 'toolkit' error mentioned in the issue. Currently GUITestAssistant is only implemented on Qt, so I also added an is_qt check before trying to get GUITestAssistant via toolkit_object, and I also skipped the test that needs qt if qt is not available. This may or may not be the right solution as the code is basically coped over from https://github.com/enthought/traitsui/blob/770e94346e06dc70909f125ba7237edce90872da/traitsui/tests/_tools.py#L50-L54

The tests no longer failed if pyface is installed but traitsui is not, or if traitsui/pyface are installed by pyside2 (or pyqt5) is not.

Checklist
- [ ] Tests
- [ ] Update API reference (docs/source/traits_api_reference)
- [ ] Update User manual (docs/source/traits_user_manual)
- [ ] Update type annotation hints in traits-stubs

from traits.testing.optional_dependencies import pyface, requires_traitsui

if pyface is not None:
GuiTestAssistant = pyface.toolkit.toolkit_object(
is_qt = ETSConfig.toolkit.startswith('qt')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the copying of this here is related to this comment:
enthought/enable#444 (review)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha, the only GUI test here is skipped if traitsui is not available and can be rewritten using UITester like this:

# this opens and closes the GUI to exercise initialization of the default traitsui editor for Enum
with UITester().create_ui(obj):
    pass

So rewriting the test not to depend on GuiTestAssistant is also an alternative...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm worried about compatibility constraints here, though. I'm not sure we want Traits 6.2.0 to depend on TraitsUI latest.

In practice, people upgrading to the latest set of ETS packages should be able to do it in two separate steps:

  1. Upgrade Traits
  2. Upgrade TraitsUI and Pyface.

OTOH, this is only in tests, so it's only the Traits test suite that ends up requiring the latest TraitsUI. I guess that doesn't affect users.

Copy link
Member

@mdickinson mdickinson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@aaronayres35 aaronayres35 merged commit 7cd836b into master Nov 16, 2020
@aaronayres35 aaronayres35 deleted the fx-test_enum-failure branch November 16, 2020 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

test_enum fails if Pyface is installed but TraitsUI is not.
3 participants