[Answer]-Test a query using Django nose

1👍

It looks like you don’t have any objects in your database, so the test fails – when you run your tests a new database is created, so data from development database is not going to be transfered into your isolated test environment.

Choose one of the available solutions:

  1. Create a fixture file, so it will hold data for all of your tests:
    https://docs.djangoproject.com/en/dev/howto/initial-data/

  2. Create objects in a setUp method or in the test method, and then try to do some asserts.

Read this first, if don’t have experience with testing in Django:
https://docs.djangoproject.com/en/1.6/topics/testing/overview/

Leave a comment