Skip to content

Commit

Permalink
FIX: files setting the toolkit crashed nosetest
Browse files Browse the repository at this point in the history
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
pberkes committed Jan 18, 2012
1 parent 490027e commit 71f6184
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 18 deletions.
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[nosetests]
where=traitsui/tests
10 changes: 10 additions & 0 deletions traitsui/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -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
9 changes: 8 additions & 1 deletion traitsui/tests/_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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:
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
@@ -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


Expand Down Expand Up @@ -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')
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 71f6184

Please sign in to comment.