Вопрос

I'm trying to use django selenium for testing my django1.3 application. The database backend for the testing is sqlite3.

Here is a snippet of my settings file.

if 'test' in sys.argv:
    DB_ENGINE = 'django.db.backends.sqlite3'
    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.sqlite3',   
            'TEST_NAME': ':memory:',  
            'NAME': 'database_one',                  
        },
        'database_two': {
            'ENGINE': 'django.db.backends.sqlite3',        ]
            'TEST_NAME': ':memory:',  
            'NAME': 'database_two',          
        },
        'database_three': {
            'ENGINE': 'django.db.backends.sqlite3',  
            'TEST_NAME': ':memory:',  
            'NAME': 'database_three',        
        },
    }
    SOUTH_TESTS_MIGRATE = False

When I run the selenium tests, I get the error saying

DatabaseError: no such table: django_session
ERROR

As a matter of fact it shows up during test creation that the tables are created in the output as follows,

Creating test database for alias 'default' (':memory:')...
Creating tables ...
Creating table django_content_type
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Creating table auth_user_user_permissions
Creating table auth_user_groups
Creating table auth_user
Creating table auth_message
Creating table django_session

I am literally stuck here as I cannot find anything about this elsewhere.

PS: The test work fine in postgres (my actual prod db engine) but I want to use sqlite3 as postgres takes a lot of time to setup & teardown db when running tests..

Thanks in advance :)

Это было полезно?

Решение

If its in memory(like in your example), the second its closed, the data disappears.

Make an actual db file, that will solve the problem. You can do this by simply giving the absolute path to the file, if there does not happen to be one, it will create one for you.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top