Django没有运行所有单元测试

时间:2015-05-18 08:11:13

标签: python django unit-testing

我正在关注tangowithdjango.com上关于单元测试的django教程。

我的代码是这样的:

from django.test import TestCase

from rango.models import Category

class CategoryMethodTests(TestCase):

    def test_ensure_views_are_positive(self):

        """
        ensure_views_are_positive
        should results True for
        categories where views
        are zero or positive
        """
        cat = Category(name='test',views=-1, likes=0)
        cat.save()
        self.assertEqual((cat.views >= 0), True)

    def test_slug_line_creation(self):
        """
        slug_line_creation checks
        to make sure that when we
        add a category an appropriate
        slug line is created

        i.e. "Random Category String"
                ->
             "random-category-string"
        """

        cat = Category(name='Random Category String')
        cat.save()
        self.assertEqual(cat.slug, 'random-category-string')

当我跑

python manage.py test rango

它工作正常,但它说1个测试运行,而实际上我有两个 另外,当我在第二次测试中编写失败的测试时,它不会抛出错误。我在这里缺少什么?

0 个答案:

没有答案