无法执行测试

麦可

文件夹结构:

.
├── db.sqlite3
├── homepage
│   ├── admin.py
│   ├── apps.py
│   ├── __init__.py
│   ├── migrations
│   │   └── __init__.py
│   ├── models.py
│   ├── tests.py
│   └── views.py
├── manage.py
├── photoarchive
│   ├── admin.py
│   ├── apps.py
│   ├── __init__.py
│   ├── migrations
│   │   └── __init__.py
│   ├── models.py
│   ├── tests.py
│   └── views.py
├── somesite
│   ├── __init__.py
│   ├── __pycache__
│   │   ├── __init__.cpython-34.pyc
│   │   ├── settings.cpython-34.pyc
│   │   ├── urls.cpython-34.pyc
│   │   └── wsgi.cpython-34.pyc
│   ├── settings.py
│   ├── urls.py
│   └── wsgi.py
└── tests
    ├── functional_test.py
    ├── __init__.py
    ├── __pycache__
    │   ├── functional_test.cpython-34.pyc
    │   ├── __init__.cpython-34.pyc
    │   └── validators.cpython-34.pyc
    └── validators.py

functional_test.py

from selenium import webdriver
from django.test import TestCase
import pdb

class HomePageTest(TestCase):
    def setUp(self):
        self.browser = webdriver.Firefox()
        self.browser.implicitly_wait(3)
        pdb.set_trace()

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


    def test_home_page(self):
        #Edith goes to home page.
        self.browser.get("http://localhost:8000")

        #Edith sees "Hello, world" in the browser title.
        estimated_browser_title ="Hello, world"
        real_browswer_title = self.browser.title 
        self.assertIn(estimated_browser_title, real_browswer_title)

我运行测试:

(venv) michael@michael:~/workspace/mysite/somesite$ python manage.py test tests
Creating test database for alias 'default'...

----------------------------------------------------------------------
Ran 0 tests in 0.000s

OK
Destroying test database for alias 'default'...

您能否帮助我理解为什么我的测试没有执行。我设置了一个pdb断点。解释器不会在该断点处停止。好吧,测试被忽略了。

你能给我踢一下吗?

丹尼尔·罗斯曼(Daniel Roseman)

Django的测试运行程序只会在INSTALLED_APPS中包含的应用程序内部发现测试。与其将代码放置在tests目录中的functional_test.py文件中,不如将其放置在其中一个应用程序目录中名为tests.py的文件中。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章