Never mind. I've found the answer. The problem was that my app name "messages" somehow clashed with the app "django.contrib.messages" which was earlier in my INSTALLED_APPS. This didn't prevent my project from working, but did confuse the test framework, which looked in "django.contrib.messages" before "myproject.messages" for test cases. When I renamed my app, the testing worked fine. So Bruno's advice was correct: give the exact details, don't simplify, that just discards important information.
OK, now to start writing serious unit tests... On Sep 5, 11:48 pm, bruno desthuilliers <bruno.desthuilli...@gmail.com> wrote: > On Sep 5, 5:18 am, Rodney Topor <r.to...@gmail.com> wrote: > > > > > > > I'm trying to use unit tests for the first time. > > > In app/tests.py I have: > > > import unittest > > from django.test.client import Client > > > class IndexTest(unittest.TestCase): > > def test_index(self): > > client = Client() > > response = client.get('/index/') > > self.assertEqual(response.status_code, 200) > > > In the enclosing project directory, I write > > > manage.py test app.IndexTest > > > and get the error > > > "Test label 'messages.IndexTest' does not refer to a test" > > You were talking about an app named "app", not "messages"... Please > try to be as exact as possible. > > > I also tried "from django.utils import unittest" in tests.py but that > > made no difference. > > > The command > > > manage.py test app > > > runs without error but ignores my test. > > I thought I was following the instructions in the documentation, but > > apparently not. What am I missing? Do I have to add some test app to > > INSTALLED_APPS in settings.py? > > Nope. As long as your app is mentionned in INSTALLED_APPS (and you'd > have a different exception if it wasn't the case), this should work. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.