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

Skip test if wx is not around #867

Merged
merged 3 commits into from
Jan 25, 2021
Merged

Skip test if wx is not around #867

merged 3 commits into from
Jan 25, 2021

Conversation

aaronayres35
Copy link
Contributor

Previously running:

python etstool.py install 
edm shell -e pyface-test-3.6-pyqt
python -m unittest

I was seeing the following test failure:

======================================================================
ERROR: pyface.ui.wx.data_view.tests.test_data_wrapper (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: pyface.ui.wx.data_view.tests.test_data_wrapper
Traceback (most recent call last):
  File "/Users/aayres/.edm/envs/pyface-test-3.6-pyqt/lib/python3.6/unittest/loader.py", line 428, in _find_test_path
    module = self._get_module_from_name(name)
  File "/Users/aayres/.edm/envs/pyface-test-3.6-pyqt/lib/python3.6/unittest/loader.py", line 369, in _get_module_from_name
    __import__(name)
  File "/Users/aayres/Desktop/pyface/pyface/ui/wx/data_view/tests/test_data_wrapper.py", line 21, in <module>
    @unittest.skipUnless(wx_available, "Test requires wx")
NameError: name 'unittest' is not defined

This PR simply updates that test file to skip the test if wx is not available in the environment.

Looking into this also made me realize that there is no consistent way this type of thing is done across the codebase. For example:

try:
from pyface.ui.wx.grid.api import GridRow, GridColumn, SimpleGridModel
except ImportError:
wx_available = False
else:
wx_available = True
@unittest.skipUnless(wx_available, "Wx is not available")

@unittest.skipIf(toolkit.toolkit == "wx", "wxPython not supported")

is_wx = (ETSConfig.toolkit == 'wx')
is_qt = ETSConfig.toolkit.startswith('qt')

USING_WX = ETSConfig.toolkit not in ["", "qt4"]

sometimes trying the import, something working with toolkit from pyface.toolkit sometimes through ETSConfig.toolkit, etc. It is pretty inconsequential (they all do what we want), but it would be good to pin down a consistent way to skip tests based on toolkit.

@rahulporuri
Copy link
Contributor

It is pretty inconsequential (they all do what we want), but it would be good to pin down a consistent way to skip tests based on toolkit.

This warrants an issue - and i'm not sure which is the best option.

Copy link
Contributor

@rahulporuri rahulporuri 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 2974f58 into master Jan 25, 2021
@aaronayres35 aaronayres35 deleted the skip-test-if-no-wx branch January 25, 2021 14:10
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.

2 participants