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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:43:35+00:00 2026-06-11T16:43:35+00:00

I like django unit tests, cause they create and drop test database on run.

  • 0

I like django unit tests, cause they create and drop test database on run.

What ways to create test database for tornado exists?

UPD: I’m interested in postgresql test database creation on test run.

  • 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-11T16:43:36+00:00Added an answer on June 11, 2026 at 4:43 pm

    I found the easiest way is just to use a SQL dump for the test database. Create a database, populate it with fixtures, and write it out to file. Simply call load_fixtures before you run your tests (or whenever you want to reset the DB). This method can certainly be improved, but it’s been good enough for my needs.

    import os
    import unittest2
    
    import tornado.database
    
    settings = dict(
        db_host="127.0.0.1:3306",
        db_name="testdb",
        db_user="testdb",
        db_password="secret",
        db_fixtures_file=os.path.join(os.path.dirname(os.path.abspath(__file__)), 'fixtures.sql'),
    )
    
    def load_fixtures():
        """Fixtures are stored in an SQL dump.
        """
        os.system("psql %s --user=%s --password=%s < %s" % (settings['db_name'], 
            settings['db_user'], settings['db_password'], settings['db_fixtures_file']))
    
        return tornado.database.Connection(
            host=settings['db_host'], database=settings['db_name'],
            user=settings['db_user'], password=settings['db_password'])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Tornado is a webserver + framework like Django but for real-time features. On my
I have some initialization code that I would like Django to run once, when
In order to pass the unit tests running on a fresh install of django
i'm starting the TDD development attitude and am writting unit-tests for my django application.
When I try to run python manage.py test in my Django (1.4) project, I
I am trying to create a url router in PHP, that works like django's.
The Django documentation ( http://docs.djangoproject.com/en/1.3/topics/testing/#running-tests ) says that you can run individual test cases
I've built up a suite of unit tests for my django project -- running
I have written a small unit test for my django view .My project structure
I have gone similar threads like Django persistent database connection and other stuff on

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.