django中的新测试模块与python 2无法正常工作

时间:2015-01-12 07:40:11

标签: python django selenium

我在 O'Reilly 跟踪了TDD,并尝试将functional_tests单独运行,如图所示here 但是我收到了错误:

ImproperlyConfigured: App with label functional_tests could not be found

目录结构如下:

├──functional_tests/

│├── init .py

│└──tests.py

├──apps/

│├──modeles.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")

请告诉我,我做错了什么?

1 个答案:

答案 0 :(得分:1)

如果您希望按照文章中显示的python manage.py test functional_tests运行测试,则应在functional_tests中保留INSTALLED_APPS个应用。并确保您的PYTHONPATH设置正确。