Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8430819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:41:25+00:00 2026-06-10T05:41:25+00:00

Django version 1.3. I am new to Django unit testing. I have written my

  • 0

Django version 1.3.

I am new to Django unit testing. I have written my first test but it fails because my login isn’t working. I’m quite sure the reason for this is that the database doesn’t contain my user account which is supposed to be provided by the auth fixture.

The code I’ve written is:

from django.test import TestCase
from django.test.client import Client

class OrderCreateTest(TestCase):
    fixtures = ['auth']

    def setUp(self):
        self.client = Client()

    def testSelectProduct(self):
        self.assertTrue(self.client.login(user='chris', password='password'),
            'Unexpected login failure.')

        response = self.client.get('/order/new/')

        print response

        self.client.logout()

    def tearDown(self):
        pass

    def runTest(self):
        pass

The test failure I’m getting is:

Creating test database for alias 'default' ('test_proj')...
Creating tables ...
...
Running post-sync handlers for application admin
...
Installing custom SQL ...
Installing indexes ...
Installing index for admin.LogEntry model
...
Running post-sync handlers for application admin
...
Loading 'initial_data' fixtures...
Checking '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/fixtures' for fixtures...
No xml fixture 'initial_data' in '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/fixtures'.
...
Checking absolute path for fixtures...
No xml fixture 'initial_data' in absolute path.
No xml fixture 'initial_data' in absolute path.
No xml fixture 'initial_data' in absolute path.
No xml fixture 'initial_data' in absolute path.
No json fixture 'initial_data' in absolute path.
No json fixture 'initial_data' in absolute path.
No json fixture 'initial_data' in absolute path.
No json fixture 'initial_data' in absolute path.
No yaml fixture 'initial_data' in absolute path.
No yaml fixture 'initial_data' in absolute path.
No yaml fixture 'initial_data' in absolute path.
No yaml fixture 'initial_data' in absolute path.
No xml fixture 'initial_data' in absolute path.
No xml fixture 'initial_data' in absolute path.
No xml fixture 'initial_data' in absolute path.
No xml fixture 'initial_data' in absolute path.
No json fixture 'initial_data' in absolute path.
No json fixture 'initial_data' in absolute path.
No json fixture 'initial_data' in absolute path.
No json fixture 'initial_data' in absolute path.
No yaml fixture 'initial_data' in absolute path.
No yaml fixture 'initial_data' in absolute path.
No yaml fixture 'initial_data' in absolute path.
No yaml fixture 'initial_data' in absolute path.
No fixtures found.
Destroying test database for alias 'default' ('test_proj')...
testSelectProduct (orpheus.orders.tests.ordercreate.OrderCreateTest) ... FAIL

======================================================================
FAIL: testSelectProduct (orpheus.orders.tests.ordercreate.OrderCreateTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/path/to/ordercreate.py", line 24, in testSelectProduct
    'Unexpected login failure.')
AssertionError: Unexpected login failure.

----------------------------------------------------------------------
Ran 1 test in 2376.829s

FAILED (failures=1)
Destroying test database for alias 'default' ('test_proj')...

Snippet from my settings with the db:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'project',
        'USER': 'project',
        'PASSWORD': 'projectdb',
        'TEST_NAME': 'test_project' } }

I’ve stepped through the test code and I can see that it’s finding my fixture auth and it’s saving the data it finds… somewhere. I’ve suspended the test to drop into mysql and queried the relevant tables but they all stay empty (the test code has been skipping the sections dealing with transactions so I’m confident that i’m not supposed to wait for a commit).

What am I doing or not doing that keeps my fixtures from loading correctly?

EDIT: I had the brilliant idea to test loading the fixture and it succeeded:

$ ./manage.py loaddata auth
Installed 8 object(s) from 1 fixture(s)

However, this doesn’t give me any ideas on how to fix the fixture loading.

EDIT: supervacuo provided a clue when he suggested I try this:

./manage.py testserver -v 2 auth.json 

The output is largely the same except that it correctly loads the fixture (mysql confirmed it):

...
Installed 8 object(s) from 1 fixture(s)
Validating models...
0 errors found

Django version 1.3, using settings 'project.settings'
Running django-devserver 0.1.4

I don’t know where to go from there.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T05:41:27+00:00Added an answer on June 10, 2026 at 5:41 am

    Problem was completely different from what it looked like. In my test I wrote:

        self.assertTrue(self.client.login(user='chris', password='password'),
            'Unexpected login failure.')
    

    When the keyword arg should instead be username. I followed the red herring of missing data in the database, which is explained by transactions.

    Thanks to mlavin in #django for the help.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Short version: I have a Django project under development & testing (not yet into
im using the new version of Sorl-thumbnail, but i cant show thumbs in django
I am new to django. I have version 1.3.1 installed. I have created two
I have a version controlled project located at ~/webapps/django/myproject and media files located at
I have used Django before (version 1.2) and generally I like it... it is
I need to start a new project with Django, but I'm not sure what
However, I am very new to django and lighttpd and have very rough idea
I'm new to python, django and google app engine. All great tools and have
I have a simple blog application written in Python, using Django. I use Git
I am new to django development (I was working with MS and Oracle/Java stack).

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.