From e37e8353218f8191f85e0111d88085c3c1dcade7 2012-05-31 20:23:29 From: Thomas Kluyver Date: 2012-05-31 20:23:29 Subject: [PATCH] Add assert_in method to nose for Python 2.6 --- diff --git a/IPython/testing/iptest.py b/IPython/testing/iptest.py index 5df454d..06b2a7e 100644 --- a/IPython/testing/iptest.py +++ b/IPython/testing/iptest.py @@ -40,6 +40,11 @@ import warnings # 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 diff --git a/IPython/testing/nose_assert_methods.py b/IPython/testing/nose_assert_methods.py new file mode 100644 index 0000000..a5adef9 --- /dev/null +++ b/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