Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/282.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.3:使用nose.tools.assert_equals时的弃用警告_Python_Deprecated_Python 3.3_Nose_Python Unittest - Fatal编程技术网

Python 3.3:使用nose.tools.assert_equals时的弃用警告

Python 3.3:使用nose.tools.assert_equals时的弃用警告,python,deprecated,python-3.3,nose,python-unittest,Python,Deprecated,Python 3.3,Nose,Python Unittest,我正在使用NoTest工具断言python: 。。。 从nose.tools导入assert_equals,assert_几乎等于 类TestPolycircles(unittest.TestCase): def设置(自): 自纬度=32.074322 self.longitude=34.792081 自半径_米=100 self.number_of_顶点=36 self.vertices=polycircles.circle(纬度=self.lation, 经度=自我经度, 半径=自半径×米,

我正在使用NoTest工具断言python:

。。。
从nose.tools导入assert_equals,assert_几乎等于
类TestPolycircles(unittest.TestCase):
def设置(自):
自纬度=32.074322
self.longitude=34.792081
自半径_米=100
self.number_of_顶点=36
self.vertices=polycircles.circle(纬度=self.lation,
经度=自我经度,
半径=自半径×米,
顶点数=自身。顶点数)
def test_顶点数(自身):
“”“断言近似多边形中的顶点数
与输入匹配。”“”
断言_等于(len(self.vertices),self.number_顶点)
...
当我运行
python setup.py test
时,会收到一条弃用警告:

...
Asserts that the number of vertices in the approximation polygon ...
/Users/adamatan/personal/polycircles/polycircles/test/test_polycircles.py:22:    
DeprecationWarning: Please use assertEqual instead.
  assert_equals(len(self.vertices), self.number_of_vertices)
ok
...

我在nose tools中找不到任何
assertEqual
。此警告来自何处,我如何修复它?

nose.tools
assert.*
函数只是为
TestCase
方法自动创建PEP8别名,因此
assert_equals
TestCase.assertEquals()相同

但是,后者只是
TestCase.assertEqual()
(注意:没有尾随的
s
)的别名。该警告旨在告诉您,您需要使用
TestCase.assertEquals()
而不是
TestCase.assertEqual()
作为测试用例

对于转换为使用
assert_equal
(无尾随
s
)的
nose.tools

如果您使用了
assert\u几乎等于
(带有尾随的
s
),您也会看到使用
assertAlmostEqual
的类似警告

from nose.tools import assert_equal, assert_almost_equal

def test_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)