加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

TDD与python书,功能测试没有找到assertRegex

发布时间:2020-12-13 20:11:02 所属栏目:百科 来源:网络整理
导读:在使用 python书进行测试驱动开发后,我陷入困境 我尝试了几种不同的进口但仍然没有…任何人? 错误 $python manage.py test functional_testsERROR: test_can_start_a_list_and_retrieve_it_later (functional_tests.tests.NewVisitorTest)-----------------
在使用 python书进行测试驱动开发后,我陷入困境
我尝试了几种不同的进口但仍然没有…任何人?

错误

$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'

from django.test import LiveServerTestCase
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import unittest

class NewVisitorTest(LiveServerTestCase):

    def setUp(self):
        self.browser = webdriver.Firefox()
        self.browser.implicitly_wait(3)

    def tearDown(self):
        self.browser.quit()

    def test_can_start_a_list_and_retrieve_it_later(self):
        # .....

        # When she hits enter,the page updates,and now the page lists
        # "1: Buy peacock feathers" as an item in a to-do list table
        inputbox.send_keys(Keys.ENTER)
        edith_list_url = self.browser.current_url
        self.assertRegex(edith_list_url,'/lists/.+')
        self.check_for_row_in_list_table('1: Buy peacock feathers')

        # ....
我假设你使用的是Python 2 – 然后使用 assertRegexpMatches而不是assertRegex.

assertRegex是在Python 3中引入的:

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读