Add assert_greater compatibility function.

Fix tests to work with nose < 1.1.3. Compatibility functions borrowed from scikit-learn.
This commit is contained in:
Tony S Yu
2012-09-13 22:17:24 -04:00
parent 051f73f2b6
commit f2d5b109e9
3 changed files with 31 additions and 2 deletions
+28
View File
@@ -0,0 +1,28 @@
"""Testing utilities."""
# Copyright (c) 2011 Pietro Berkes
# License: Simplified BSD
def _assert_less(a, b, msg=None):
message = "%r is not lower than %r" % (a, b)
if msg is not None:
message += ": " + msg
assert a < b, message
def _assert_greater(a, b, msg=None):
message = "%r is not greater than %r" % (a, b)
if msg is not None:
message += ": " + msg
assert a > b, message
try:
from nose.tools import assert_less
except ImportError:
assert_less = _assert_less
try:
from nose.tools import assert_greater
except ImportError:
assert_greater = _assert_greater
@@ -1,6 +1,6 @@
import numpy as np
from numpy.testing import assert_equal, assert_array_equal
from nose.tools import assert_greater
from skimage._shared.testing import assert_greater
from skimage.segmentation import felzenszwalb
@@ -1,6 +1,7 @@
import numpy as np
from numpy.testing import assert_equal, assert_array_equal
from nose.tools import assert_true, assert_greater
from nose.tools import assert_true
from skimage._shared.testing import assert_greater
from skimage.segmentation import quickshift