(DatabaseError:没有这样的表:django_session)在Django 1.3硒测试期间错误 [英] (DatabaseError: no such table: django_session) ERROR during Django 1.3 selenium testing

查看:260
本文介绍了(DatabaseError:没有这样的表:django_session)在Django 1.3硒测试期间错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用django selenium来测试我的django1.3应用程序。测试的数据库后端是sqlite3。

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:测试工作在postgres(我的实际的prod db引擎)但是我想使用sqlite3作为postgres需要很多时间来设置up&运行测试时,拆卸数据库。

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..

提前感谢:)

推荐答案

p>如果在内存中(如在你的例子中),第二个关闭,数据就会消失。

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.

这篇关于(DatabaseError:没有这样的表:django_session)在Django 1.3硒测试期间错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆