python 2 不工作的 django 中的新测试模块
New test module in django with python 2 not working
我在 O'Reilly and I tried to make the functional_tests to run in isolation as shown here 关注 TDD
但我收到错误:
ImproperlyConfigured: App with label functional_tests could not be found
目录结构如下:
├── functional_tests/
│ ├── init.py
│ └── tests.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 设置正确。
我在 O'Reilly and I tried to make the functional_tests to run in isolation as shown here 关注 TDD 但我收到错误:
ImproperlyConfigured: App with label functional_tests could not be found
目录结构如下:
├── functional_tests/
│ ├── init.py
│ └── tests.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 设置正确。