开发者

Django not running tests with manage.py test, unless an app and a specific test method is specified

I have a Django application, myApp. In it, there's a tests.py file which defines a number of test cases using django.test.TestCase class. For example, one of them is called WebViews, and has a test method check_status_codes.

When I run ./manage.py test, the database is built with my initial data, but then it tells me that it ran 0 tests. I get similar results (tests not running) if I do this:

./manage.py test myApp

or even this:

./manage.py test myApp.WebViews

However, if I execute

./manage.py test.WebViews.check_status_codes

then that exact test method ru开发者_StackOverflow中文版ns as expected.

I can string bunch of test methods together like this and get them to run, but this gets very tedious and I have a feeling I'm missing something.

Any hints or suggestions regarding what to do?

Thanks!


I believe the convention with unit tests is to have your test methods pre-pended with test. For example:

class FooTest(TestCase):

    def setUp(self):
        # do setup stuff here
        pass

    def tearDown(self):
        # do teardown here
        pass

    def test_one_equals_one(self):
        self.assertEqual(1, 1, "One did not equal 1")
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜