"""\r
\r
from math import sqrt\r
-from py.test import raises\r
+from nose.tools import assert_raises\r
from django.core.paginator import Paginator\r
import django_tables as tables\r
\r
\r
# optionally, exceptions can be raised when input is invalid\r
tables.options.IGNORE_INVALID_OPTIONS = False\r
- raises(Exception, "stuff.order_by = '-name,made-up-column'")\r
- raises(Exception, "stuff.order_by = ('made-up-column',)")\r
- # when a column name is overwritten, the original won't work anymore\r
- raises(Exception, "stuff.order_by = 'c'")\r
- # reset for future tests\r
- tables.options.IGNORE_INVALID_OPTIONS = True\r
+ try:\r
+ assert_raises(ValueError, setattr, stuff, 'order_by', '-name,made-up-column')\r
+ assert_raises(ValueError, setattr, stuff, 'order_by', ('made-up-column',))\r
+ # when a column name is overwritten, the original won't work anymore\r
+ assert_raises(ValueError, setattr, stuff, 'order_by', 'c')\r
+ # reset for future tests\r
+ finally:\r
+ tables.options.IGNORE_INVALID_OPTIONS = True\r
\r
def test_caches():\r
"""Ensure the various caches are effective.\r
test_order('id', [1,2,3,4])\r
test_order('-id', [4,3,2,1])\r
# a invalid direction string raises an exception\r
- raises(ValueError, "books.base_columns['id'].direction = 'blub'")\r
+ assert_raises(ValueError, setattr, books.base_columns['id'], 'direction', 'blub')\r
\r
# [bug] test alternative order formats if passed to constructor\r
BookTable([], 'language,-num_pages')\r
Sets up a temporary Django project using a memory SQLite database.\r
"""\r
\r
-from py.test import raises\r
+from nose.tools import assert_raises\r
from django.conf import settings\r
from django.core.paginator import *\r
import django_tables as tables\r
assert not 'id' in r\r
# [bug] access to data that might be available, but does not\r
# have a corresponding column is denied.\r
- raises(Exception, "r['id']")\r
+ assert_raises(Exception, "r['id']")\r
# missing data is available with default values\r
assert 'null' in r\r
assert r['null'] == "foo" # note: different from prev. line!\r