Browse files

FIX: files setting the toolkit crashed nosetest

There were sub-modules and tests setting the
backend explicitly, which crashed nosetest.

- moved all two tests to the traitsui.tests module

- setup.cfg tells nose where to look
  • Loading branch information...
1 parent 490027e commit 71f6184061d8448dfc93af46a4a026536f84443a @pberkes pberkes committed Jan 18, 2012
View
2 setup.cfg
@@ -0,0 +1,2 @@
+[nosetests]
+where=traitsui/tests
View
10 traitsui/tests/__init__.py
@@ -0,0 +1,10 @@
+# Run tests using nose:
+# $ nosetests -v
+#
+# The tests that are not compatible with the selected toolkit will be skipped
+# (resulting in 'S' characters in the report). To test different backend,
+# you should set the backend using the environment variable ETS_TOOLKIT:
+#
+# $ ETS_TOOLKIT='qt4' nosetests -v
+# $ ETS_TOOLKIT='wx' nosetests -v
+# $ ETS_TOOLKIT='null' nosetests -v
View
9 traitsui/tests/_tools.py
@@ -86,12 +86,19 @@ def test_func():
#: Return True if current backend is 'qt4'
is_current_backend_qt4 = partial(_is_current_backend, backend_name='qt4')
+#: Return True if current backend is 'null'
+is_current_backend_null = partial(_is_current_backend, backend_name='null')
+
+
#: Test decorator: Skip test if backend is not 'wx'
skip_if_not_wx = partial(skip_if_not_backend, backend_name='wx')
#: Test decorator: Skip test if backend is not 'qt4'
skip_if_not_qt4 = partial(skip_if_not_backend, backend_name='qt4')
+#: Test decorator: Skip test if backend is not 'null'
+skip_if_not_null = partial(skip_if_not_backend, backend_name='null')
+
def count_calls(func):
"""Decorator that stores the number of times a function is called.
@@ -192,7 +199,7 @@ def destroy_wrapped():
def wx_find_event_by_number(evt_num):
- """Find all wx event names that correspond to a ceratin event number.
+ """Find all wx event names that correspond to a certain event number.
Example:
View
0 traitsui/editors/tests/__init__.py → traitsui/tests/editors/__init__.py
File renamed without changes.
View
2 traitsui/tests/test_csv_editor.py → traitsui/tests/editors/test_csv_editor.py
@@ -21,7 +21,7 @@
from traitsui.editors.csv_list_editor import CSVListEditor
import traitsui.editors.csv_list_editor as csv_list_editor
-from _tools import *
+from traitsui.tests._tools import *
class ListOfFloats(HasTraits):
View
24 ...ui/editors/tests/test_default_override.py → ...ui/tests/editors/test_default_override.py
@@ -1,9 +1,7 @@
-from __future__ import absolute_import
-
from nose.tools import assert_equals
-from ...api import DefaultOverride, EditorFactory
+from traitsui.api import DefaultOverride, EditorFactory
from traits.api import HasTraits, Int
@@ -33,45 +31,47 @@ def create_editor(self):
class Dummy(HasTraits):
x = NewInt()
-object = Dummy()
+
+dummy_object = Dummy()
do = DefaultOverride(x=15, y=25, format_str='%r')
+
def test_simple_override():
- editor_name, editor, ui, obj, name, description, parent = do.simple_editor('ui', object, 'x', 'description', 'parent')
+ editor_name, editor, ui, obj, name, description, parent = do.simple_editor('ui', dummy_object, 'x', 'description', 'parent')
assert_equals(editor_name, 'simple_editor')
assert_equals(editor.x, 15)
assert_equals(editor.y, 25)
- assert_equals(obj, object)
+ assert_equals(obj, dummy_object)
assert_equals(name, 'x')
assert_equals(description, 'description')
assert_equals(parent, 'parent')
def test_text_override():
- editor_name, editor, ui, obj, name, description, parent = do.text_editor('ui', object, 'x', 'description', 'parent')
+ editor_name, editor, ui, obj, name, description, parent = do.text_editor('ui', dummy_object, 'x', 'description', 'parent')
assert_equals(editor_name, 'text_editor')
assert_equals(editor.x, 15)
assert_equals(editor.y, 25)
- assert_equals(obj, object)
+ assert_equals(obj, dummy_object)
assert_equals(name, 'x')
assert_equals(description, 'description')
assert_equals(parent, 'parent')
def test_custom_override():
- editor_name, editor, ui, obj, name, description, parent = do.custom_editor('ui', object, 'x', 'description', 'parent')
+ editor_name, editor, ui, obj, name, description, parent = do.custom_editor('ui', dummy_object, 'x', 'description', 'parent')
assert_equals(editor_name, 'custom_editor')
assert_equals(editor.x, 15)
assert_equals(editor.y, 25)
- assert_equals(obj, object)
+ assert_equals(obj, dummy_object)
assert_equals(name, 'x')
assert_equals(description, 'description')
assert_equals(parent, 'parent')
def test_readonly_override():
- editor_name, editor, ui, obj, name, description, parent = do.readonly_editor('ui', object, 'x', 'description', 'parent')
+ editor_name, editor, ui, obj, name, description, parent = do.readonly_editor('ui', dummy_object, 'x', 'description', 'parent')
assert_equals(editor_name, 'readonly_editor')
assert_equals(editor.x, 15)
assert_equals(editor.y, 25)
- assert_equals(obj, object)
+ assert_equals(obj, dummy_object)
assert_equals(name, 'x')
assert_equals(description, 'description')
assert_equals(parent, 'parent')
View
2 traitsui/tests/test_range_editor_spinner.py → ...ests/editors/test_range_editor_spinner.py
@@ -31,7 +31,7 @@
from traitsui.view import View
from traitsui.editors.range_editor import RangeEditor
-from _tools import *
+from traitsui.tests._tools import *
class NumberWithSpinnerEditor(HasTraits):
View
2 traitsui/tests/test_range_editor_text.py → ...i/tests/editors/test_range_editor_text.py
@@ -25,7 +25,7 @@
from traitsui.view import View
from traitsui.editors.range_editor import RangeEditor
-from _tools import *
+from traitsui.tests._tools import *
class NumberWithTextEditor(HasTraits):
View
0 traitsui/tests/null_backend/__init__.py
No changes.
View
5 traitsui/null/tests/test_font_trait.py → ...sui/tests/null_backend/test_font_trait.py
@@ -3,17 +3,18 @@
from traits.api import HasTraits, Font
-from traits.etsconfig.api import ETSConfig
-ETSConfig.toolkit = 'null'
+from traitsui.tests._tools import *
+@skip_if_not_null
def test_font_trait_default():
class Foo(HasTraits):
font = Font()
f = Foo()
assert_equals(f.font, '10 pt Arial')
+@skip_if_not_null
def test_font_trait_examples():
"""
An assigned font string is parsed, and the substrings are

0 comments on commit 71f6184

Please sign in to comment.