gpt4 book ai didi

python - Django 中的新测试模块与 python 2 不工作

转载 作者:太空宇宙 更新时间:2023-11-03 17:59:45 25 4
gpt4 key购买 nike

我在 O'Reilly 关注TDD我尝试使功能测试独立运行,如图 here 但我收到错误:

ImproperlyConfigured: App with label functional_tests could not be found

目录结构如下:

├──功能测试/

│ ├── init.py

│ └── 测试.py

├── 应用程序/

│ ├── models.py

...

tests.py 包含以下代码:

from django.test.client import Client
from django.contrib.auth.models import User
from django.test import LiveServerTestCase

from selenium import webdriver
from selenium.webdriver.common.keys import Keys


class FunctionalTest(LiveServerTestCase):

def setUp(self):
self.browser = webdriver.Firefox()
self.browser.implicitly_wait(3)
self.c = Client()
self.user = User.objects.create_user(
username="admin", email="admin@agiliq.com", password="admin")

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

def test_admin_login(self):
self.browser.get(self.live_server_url)
# login = self.browser.find_element_by_link_text("Login")

请告诉我我做错了什么?

最佳答案

如果您想使用 python manage.py test functional_tests 运行测试正如文章中所示,您应该保留 functional_tests应用程序在 INSTALLED_APPS 。并确保您的 PYTHONPATH 设置正确。

关于python - Django 中的新测试模块与 python 2 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27897307/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com