Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 runs 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!

like image 420
lunafiko Avatar asked Dec 10 '10 21:12

lunafiko


1 Answers

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")
like image 151
ashchristopher Avatar answered Sep 17 '22 21:09

ashchristopher