From c5d195b142e1c53530ad4341974acbf187ae6aaf Mon Sep 17 00:00:00 2001 From: Michael Elsdoerfer Date: Tue, 16 Sep 2008 19:43:01 +0200 Subject: [PATCH] converted test suite to use nose rather than py.test; made some minor improvements to one test in the process --- README | 3 ++- tests/test_basic.py | 18 ++++++++++-------- tests/test_models.py | 4 ++-- tests/test_templates.py | 1 - 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/README b/README index 5b68aa2..6445f20 100644 --- a/README +++ b/README @@ -13,7 +13,8 @@ apart from that, ``import django_tables as tables`` should get you going. Running the test suite ---------------------- -The test suite uses py.test (from http://codespeak.net/py/dist/test.html). +The test suite uses nose: + http://somethingaboutorange.com/mrl/projects/nose/ Working with Tables ------------------- diff --git a/tests/test_basic.py b/tests/test_basic.py index 5484062..5b4e65a 100644 --- a/tests/test_basic.py +++ b/tests/test_basic.py @@ -4,7 +4,7 @@ This includes the core, as well as static data, non-model tables. """ from math import sqrt -from py.test import raises +from nose.tools import assert_raises from django.core.paginator import Paginator import django_tables as tables @@ -97,12 +97,14 @@ def test_basic(): # optionally, exceptions can be raised when input is invalid tables.options.IGNORE_INVALID_OPTIONS = False - raises(Exception, "stuff.order_by = '-name,made-up-column'") - raises(Exception, "stuff.order_by = ('made-up-column',)") - # when a column name is overwritten, the original won't work anymore - raises(Exception, "stuff.order_by = 'c'") - # reset for future tests - tables.options.IGNORE_INVALID_OPTIONS = True + try: + assert_raises(ValueError, setattr, stuff, 'order_by', '-name,made-up-column') + assert_raises(ValueError, setattr, stuff, 'order_by', ('made-up-column',)) + # when a column name is overwritten, the original won't work anymore + assert_raises(ValueError, setattr, stuff, 'order_by', 'c') + # reset for future tests + finally: + tables.options.IGNORE_INVALID_OPTIONS = True def test_caches(): """Ensure the various caches are effective. @@ -203,7 +205,7 @@ def test_sort(): test_order('id', [1,2,3,4]) test_order('-id', [4,3,2,1]) # a invalid direction string raises an exception - raises(ValueError, "books.base_columns['id'].direction = 'blub'") + assert_raises(ValueError, setattr, books.base_columns['id'], 'direction', 'blub') # [bug] test alternative order formats if passed to constructor BookTable([], 'language,-num_pages') diff --git a/tests/test_models.py b/tests/test_models.py index a2aff04..fc7838b 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -3,7 +3,7 @@ Sets up a temporary Django project using a memory SQLite database. """ -from py.test import raises +from nose.tools import assert_raises from django.conf import settings from django.core.paginator import * import django_tables as tables @@ -112,7 +112,7 @@ def test_basic(): assert not 'id' in r # [bug] access to data that might be available, but does not # have a corresponding column is denied. - raises(Exception, "r['id']") + assert_raises(Exception, "r['id']") # missing data is available with default values assert 'null' in r assert r['null'] == "foo" # note: different from prev. line! diff --git a/tests/test_templates.py b/tests/test_templates.py index 80c4f41..bc304e6 100644 --- a/tests/test_templates.py +++ b/tests/test_templates.py @@ -6,7 +6,6 @@ via templates or otherwise. Whether a test belongs here or, say, in ``test_basic``, is not always a clear-cut decision. """ -from py.test import raises from django.template import Template, Context, add_to_builtins from django.http import HttpRequest import django_tables as tables -- 2.26.2