mercredi 28 octobre 2015

Structuring Django Testing & Test wont run

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

Aucun commentaire:

Enregistrer un commentaire