newcomer to django testing

65 views
Skip to first unread message

monoBOT

unread,
Jun 8, 2014, 5:21:48 AM6/8/14
to django...@googlegroups.com
Im new on testing ... to be honest its my first django test XD

Now i wanted to test one of my applications and after the innitial tweaking of allowing the django user to be able to create databases i get this error:

​The error was: relation "usuario_usuario" does not exist

Error in migration: comunidad:0001_initial
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/test.py", line 50, in run_from_argv
    super(Command, self).run_from_argv(argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 242, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/test.py", line 71, in execute
    super(Command, self).execute(*args, **options)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 285, in execute
    output = self.handle(*args, **options)
  File "/home/monobot/.local/lib/python2.7/site-packages/south/management/commands/test.py", line 8, in handle
    super(Command, self).handle(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/test.py", line 88, in handle
    failures = test_runner.run_tests(test_labels)
  File "/usr/local/lib/python2.7/dist-packages/django/test/runner.py", line 145, in run_tests
    old_config = self.setup_databases()
  File "/usr/local/lib/python2.7/dist-packages/django/test/runner.py", line 107, in setup_databases
    return setup_databases(self.verbosity, self.interactive, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/django/test/runner.py", line 279, in setup_databases
    verbosity, autoclobber=not interactive)
  File "/home/monobot/.local/lib/python2.7/site-packages/south/hacks/django_1_0.py", line 104, in wrapper
    return f(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/creation.py", line 339, in create_test_db
    load_initial_data=False)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 159, in call_command
    return klass.execute(*args, **defaults)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 285, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 415, in handle
    return self.handle_noargs(**options)
  File "/home/monobot/.local/lib/python2.7/site-packages/south/management/commands/syncdb.py", line 103, in handle_noargs
    management.call_command('migrate', **options)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 159, in call_command
    return klass.execute(*args, **defaults)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 285, in execute
    output = self.handle(*args, **options)
  File "/home/monobot/.local/lib/python2.7/site-packages/south/management/commands/migrate.py", line 111, in handle
    ignore_ghosts = ignore_ghosts,
  File "/home/monobot/.local/lib/python2.7/site-packages/south/migration/__init__.py", line 220, in migrate_app
    success = migrator.migrate_many(target, workplan, database)
  File "/home/monobot/.local/lib/python2.7/site-packages/south/migration/migrators.py", line 305, in migrate_many
    result = self.migrate(migration, database)
  File "/home/monobot/.local/lib/python2.7/site-packages/south/migration/migrators.py", line 134, in migrate
    result = self.run(migration, database)
  File "/home/monobot/.local/lib/python2.7/site-packages/south/migration/migrators.py", line 115, in run
    return self.run_migration(migration, database)
  File "/home/monobot/.local/lib/python2.7/site-packages/south/migration/migrators.py", line 86, in run_migration
    south.db.db.execute_deferred_sql()
  File "/home/monobot/.local/lib/python2.7/site-packages/south/db/generic.py", line 318, in execute_deferred_sql
    self.execute(sql)
  File "/home/monobot/.local/lib/python2.7/site-packages/south/db/generic.py", line 282, in execute
    cursor.execute(sql, params)
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/util.py", line 53, in execute
    return self.cursor.execute(sql, params)
  File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 99, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/util.py", line 53, in execute
    return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: relation "usuario_usuario" does not exist

So you could understand usuario is 1 of my apps and Usuario is one model in there and i use south in my application.

Seems that the test module needs an already functional database before testing but that isnt ilogical because it deletes the database and creates 1other database...


Any help would be welcomed.

--
monoBOT
Visite mi sitio(Visit my site): monobotblog.alvarezalonso.es

Esau Rodriguez

unread,
Jun 8, 2014, 10:42:15 AM6/8/14
to django...@googlegroups.com
The testing process creates db itself when using south it migrate all
apps with migrations. Could you have a problem with your migrations
when run from zero?.

Regards
Esau Rodriguez.
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users...@googlegroups.com.
> To post to this group, send email to django...@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CA%2BxOsGCEzE6M9SHs2MFfk-XGmNSyUSsBdn6Hz-ypfH7E%3D-CjiA%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.



--
Esaú Rodríguez
esa...@gmail.com

monoBOT

unread,
Jun 8, 2014, 1:10:55 PM6/8/14
to django...@googlegroups.com
Hi Esau.

Funny to see you here ;.D

I checked what you told me and its true ... if I try to create the database starting with the comunidad table it  raises the error but when starting the migrations with usuario it goes smooth.

Simply changing the app order in the settings.py file fixed the problem ...

Thanks mate



For more options, visit https://groups.google.com/d/optout.



--

Andromeda Yelton

unread,
Jun 9, 2014, 8:37:12 PM6/9/14
to django...@googlegroups.com
You can also add a depends_on statement to your south migrations, if you really need them to run in a particular order: http://south.readthedocs.org/en/latest/dependencies.html



For more options, visit https://groups.google.com/d/optout.



--
Andromeda Yelton
Board of Directors, Library & Information Technology Association: http://www.lita.org
Advisor, Ada Initiative: http://adainitiative.org
Reply all
Reply to author
Forward
0 new messages