Prevent test_enum failures if traitsui or GUI toolkit are not installed #1349
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.
Fixes #1266
In this PR I first simply broke
pyface.toolkit.toolkit_object
up intofrom pyface.toolkit import toolkit_object
and then calledtoolkit_object
. This fixed theAttributeError: module 'pyface' has no attribute 'toolkit'
error mentioned in the issue. CurrentlyGUITestAssistant
is only implemented on Qt, so I also added anis_qt
check before trying to getGUITestAssistant
viatoolkit_object
, and I also skipped the test that needsqt
ifqt
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-L54The 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 intraits-stubs