无法让Django运行简单的单元测试

时间:2013-07-05 13:34:12

标签: python django unit-testing

我在名为testDummy.py的文件中有一个最小的测试用例,该文件位于/MyApp/MyApp/(与默认settings.py一起)

from django.test import TestCase

class DummyTests(TestCase):

    def setUp(self):
        print("Setup")

    def tearDown(self):
        print("Teardown")

    def test_noddy(self):

        self.assertEqual(1, 2)

执行manage.py test -v 2时,我得到......

Creating test database for alias 'default' ('test_myapp')...
Creating tables ...
Creating table django_content_type
Creating table contenttypes_concretemodel
...
Creating table myapp_login_audit
Installing custom SQL ...
Installing indexes ...
Installed 0 object(s) from 0 fixture(s)
test_get_for_concrete_model (django.contrib.contenttypes.tests.ContentTypesTests) ... ok
...
test_shortcut_view (django.contrib.contenttypes.tests.ContentTypesTests) ... ok
test_shortcut_view_with_broken_get_absolute_url (django.contrib.contenttypes.tes
ts.ContentTypesTests) ... ok
test_shortcut_view_without_get_absolute_url (django.contrib.contenttypes.tests.C
ontentTypesTests) ... ok

----------------------------------------------------------------------
Ran 10 tests in 0.389s

OK
Destroying test database for alias 'default' ('test_myapp')...

然而,它总是运行相同的10个测试(没有一个是我的)。如果我manage.py test -v 2 MyApp,则运行0次测试。

我错过了什么?

(Python3,Django 1.6)

0 个答案:

没有答案