Skip to content Skip to sidebar Skip to footer

Python 3.3: Deprecationwarning When Using Nose.tools.assert_equals

I am using nosetest tools for asserting a python unittest: ... from nose.tools import assert_equals, assert_almost_equal class TestPolycircles(unittest.TestCase): def setUp(s

Solution 1:

The nose.toolsassert_* functions are just automatically created PEP8 aliases for the TestCase methods, so assert_equals is the same as TestCase.assertEquals().

However, the latter was only ever an alias for TestCase.assertEqual() (note: no trailing s). The warning is meant to tell you that instead of TestCase.assertEquals() you need to use TestCase.assertEqual() as the alias has been deprecated.

For nose.tools that translates into using assert_equal (no trailing s):

from nose.tools import assert_equal, assert_almost_equal

deftest_number_of_vertices(self):
    """Asserts that the number of vertices in the approximation polygon
    matches the input."""
    assert_equal(len(self.vertices), self.number_of_vertices)

Had you used assert_almost_equals (with trailing s), you'd have seen a similar warning to use assertAlmostEqual, as well.

Post a Comment for "Python 3.3: Deprecationwarning When Using Nose.tools.assert_equals"