Browse files

Add assert_in method to nose for Python 2.6

  • Loading branch information...
1 parent e605f72 commit e37e8353218f8191f85e0111d88085c3c1dcade7 @takluyver committed May 31, 2012
Showing with 16 additions and 0 deletions.
  1. +5 −0 IPython/testing/iptest.py
  2. +11 −0 IPython/testing/nose_assert_methods.py
View
5 IPython/testing/iptest.py
@@ -40,6 +40,11 @@
# it for actual use. This should get into nose upstream, but its release cycle
# is slow and we need it for our parametric tests to work correctly.
from IPython.testing import nosepatch
+
+# Monkeypatch extra assert methods into nose.tools if they're not already there.
+# This can be dropped once we no longer test on Python 2.6
+from IPython.testing import nose_assert_methods
+
# Now, proceed to import nose itself
import nose.plugins.builtin
from nose.plugins.xunit import Xunit
View
11 IPython/testing/nose_assert_methods.py
@@ -0,0 +1,11 @@
+"""Add some assert methods to nose.tools. These were added in Python 2.7/3.1, so
+once we stop testing on Python 2.6, this file can be removed.
+"""
+
+import nose.tools as nt
+
+def assert_in(item, collection):
+ assert item in collection, '%r not in %r' % (item, collection)
+
+if not hasattr(nt, 'assert_in'):
+ nt.assert_in = assert_in

0 comments on commit e37e835

Please sign in to comment.