error using runtests.py with a reusable application

11 views
Skip to first unread message

Danielta

unread,
Feb 15, 2017, 2:37:38 PM2/15/17
to Django users
Hi,
I'm developing unit tests for simple Models that interact with a MySQL database.

The app is configured as reusable application as indicated here:

and the tests are created according to the structure stated here using runtests.py:
https://docs.djangoproject.com/en/1.10/topics/testing/overview/

the admin interface is working correctly, and database is updated with the correct data but

when I run:

python runtests.py

I get the following error:
RuntimeError: Model class surrogate.models.Person.Person doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.

any idea about the error?

here the bits of code interested by the error:

the Person test is (in myapp/tests/tests.py):
class PersonTestCase(TestCase):
 
def setup(self):
 
Person.objects.create(name="adam", surname="felix")

 
def test_animals_can_speak(self):
 person1
= Person.objects.get(name="adam")
 
self.assertEqual(person1, 'test')

Person model (myapp/models/Person/Person.py) is:


from django.db import models
from django import utils
import uuid


class Person(models.Model):
 id
= models.BigAutoField(primary_key=True, editable=False)
 uuid
= models.UUIDField( default=uuid.uuid4, editable=False)
 name
= models.CharField(max_length=100)
 surname
= models.CharField(max_length=100)
 email
= models.EmailField()
 creation_date
= models.DateField(default=utils.timezone.now)

 
def __str__(self): # __unicode__ on Python 2
 
return self.surname



cheers
D
Reply all
Reply to author
Forward
0 new messages