2

I am new to django testing & I am trying to write some unit tests for my Django project but when i moved tests to a new folder. I am getting the following message.

Creating test database for alias 'default'...

----------------------------------------------------------------------
Ran 0 tests in 0.000s # <======== ATTENTION

OK
Destroying test database for alias 'default'...

The tests were passing successfully.

python manage.py test public --traceback

Old structure

project |
  public | #app
     tests.py|
  private | #app
     tests.py

New structure

project |
  public | #app
     tests|
        __init__.py
        test_users.py
        test_models.py
        test_forms.py
  private | #app
     tests.py

With the structure I am unable to run tests.

test_users.py

class UserGroupCase(TestCase):
    def setUp(self):
        super(TestCase, self).setUp()
        self.groups = ["Regular", "Photographer", "Blogist"]
        for group in self.groups:
            Group.objects.create(name=group)

    def test_adding_user_in_group(self):
        self.assertTrue(len(self.groups), 2)
        regular = Group.objects.get(name=self.groups[0])
        photographer = Group.objects.get(name=self.groups[1])
        blogist = Group.objects.get(name=self.groups[2])

        robo1 = MyUser.objects.get(username="robot1")

        regular.user_set.add(robo1)

Please help out what I am missing here.

Django1.5.1
1
  • Strange behavior. I am using the following project structure and I am able to run tests with just ./manage.py test project Commented Oct 29, 2015 at 9:58

1 Answer 1

2

I have found the answer, Posting it here as it might be helpful for others. its related to DJANGO 1.5

You can add tests to test/anydir/anydir1/test_user.py, but import every test to tests/__init__.py up until django 1.5.

Also there is a test runner which will work the way unittest2 discovery work. This functionality has been integrated into django1.6.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.