用python编写的TDD,函数测试找不到assertRegex

2024-09-30 18:24:37 发布

您现在位置:Python中文网/ 问答频道 /正文

在使用pythonbook进行测试驱动开发之后,我陷入了困境 我试过几种不同的进口货,但还是没有。。有人吗?在

错误

$python manage.py test functional_tests
ERROR: test_can_start_a_list_and_retrieve_it_later (functional_tests.tests.NewVisitorTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/coelhao/DjangoProjects/superlists/functional_tests/tests.py", line 45, in
test_can_start_a_list_and_retrieve_it_later
self.assertRegex(edith_list_url, '/lists/.+') AttributeError: 'NewVisitorTest' object has no attribute 'assertRegex' 

代码

^{pr2}$

Tags: andpytesttestsitstartcanlist
2条回答

没有assertRegex这样的断言——也许你是说assertRegexMatches?在

unittest文档在这里:http://docs.python.org/2.7/library/unittest.html#unittest.TestCase

我假设您使用Python2—然后使用^{}而不是{}。在

在Python 3中引入了^{}

Changed in version 3.2: The method assertRegexpMatches() has been renamed to assertRegex().

相关问题 更多 >