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 1113769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:54:22+00:00 2026-05-17T02:54:22+00:00

Im looking to learn more about your testing flows with Django. Background information http://docs.djangoproject.com/en/dev/topics/testing/

  • 0

Im looking to learn more about your testing flows with Django.

Background information
http://docs.djangoproject.com/en/dev/topics/testing/

Im encountering difficulties when using test driven development.
The test runner of Django constantly creates all db models in a test db when starting.
For our current projects (between 40 and 240 models) this means it takes easily 20s for tests to start.

This makes it completely unworkable for testing a new feature often.
My question, how do you guys work around this?

I’ve tried a few things in the past
a.) – change the testloader to reuse the same test db every time and apply migrations when needed
b.) – run my unit tests from within the __main__ flow of python files

option b is awkward with the sys.path, option a is doable but doesnt seem to be the django way.

Update:
Option A is indeed not such a bad solution. Its just quite a bit of effort. Which makes me believe people use a different workaround. SQL lite could be that workaround. But im guessing there are more.

  • 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-05-17T02:54:22+00:00Added an answer on May 17, 2026 at 2:54 am

    change the testloader to reuse the same test db every time and apply migrations when needed

    1. I don’t see anything wrong in writing your own test runner that merely truncates the tables instead of dropping and creating the database. This is djangoic in that it solves a specific problem. There is a ticket open for allowing grouping of test cases into test suites. Once it is fixed you should be able to group your test cases into suites for easier management. You can also inspect the patch attached to the ticket and see if it will suit your purpose.

    2. As Ned suggested you can use an in memory database. This depends to a large extent on your data model and queries being portable across databases.

    3. If you haven’t already try to reorganize your test cases. In my experience not all test classes need to sub class django.test.TestCase. Find out those test classes that can do with sub classing unittest.TestCase. This will speed up things a little bit.

    4. Reorganize fixtures. Move common fixtures to a single file and load it before the test run rather than inside each test class (using fixtures = [...]).

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

Sidebar

Related Questions

I am looking to learn more about threading and I wanted to know: what
While looking at some open source code to learn more about J2EE, I came
I am looking to implement and learn more about the ASP.NET GridView control. However,
I am constantly looking to learn more about MVVM but I feel like I
I am creating a custom CMS, with the purpose to learn more about Django.
I was looking to implement such menu as http://www.fogcreek.com/FogBugz/learnmore.html (Left hand side) Can anyone
I'm looking to learn some theory about data/audio/video compression, and would be glad to
In order to learn more about Heaps, I implemented my own MaxHeap class. I
In an effort to learn more about php and mysql, I have been working
I'm looking for some information about the roll-out of a python project that uses

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.