多线程django测试设置的共享数据库连接。
django-shareddb的Python项目详细描述
django shareddb
===
此代理数据库后端旨在加快多线程测试设置。
``这需要在每次测试之间刷新整个数据库。
它不是**用于生产,只用于更快的测试设置。
本项目支持django版本1.6和python 2.7、3.2和3.3。
setup
----
首先,安装django shareddb:
。代码块::shel
$pip安装django shareddb
然后,只需更新设置即可使用其包装引擎:
…代码块::python
databases={
'默认值':{
'引擎':'shareddb.backends.shareddb',
'内部引擎':'django.db.backends.postgresql'u psycopg2',
'名称':'test dbsharing',
}
}
django shareddb还提供了一个简单的“补丁数据库”功能:
…代码块::python
databases={
'默认值':{
'引擎':'django.db.backends.postgresql_psycopg2',
'名称':'测试数据库共享',
}
}
注意:``patch_databases``接受两个关键字参数,
``whitelist```(只改变列表中的数据库)和
``blacklist``(从不改变列表中的数据库)。
`blacklist``的优先级高于``whitelist``。
只需用django shareddb变量替换对django的liveservertestcase的调用:
…代码块:python
from shareddb import testcases
class mytests(testcases.liveservertestcase):
def test_something(self):
但使用“django.test.testcase”而不是“django.test.transactiontestcase”。
在github上打开:https://github.com/rbarrois/django shareddb/issues
testing
----
>此库已通过sqlite和postgresql成功测试。
如果要使用其他数据库测试它,请克隆它并更改
``dev/settings.py``以安装程序,然后运行``./manage.py test``。
===
此代理数据库后端旨在加快多线程测试设置。
``这需要在每次测试之间刷新整个数据库。
它不是**用于生产,只用于更快的测试设置。
本项目支持django版本1.6和python 2.7、3.2和3.3。
setup
----
首先,安装django shareddb:
。代码块::shel
$pip安装django shareddb
然后,只需更新设置即可使用其包装引擎:
…代码块::python
databases={
'默认值':{
'引擎':'shareddb.backends.shareddb',
'内部引擎':'django.db.backends.postgresql'u psycopg2',
'名称':'test dbsharing',
}
}
django shareddb还提供了一个简单的“补丁数据库”功能:
…代码块::python
databases={
'默认值':{
'引擎':'django.db.backends.postgresql_psycopg2',
'名称':'测试数据库共享',
}
}
注意:``patch_databases``接受两个关键字参数,
``whitelist```(只改变列表中的数据库)和
``blacklist``(从不改变列表中的数据库)。
`blacklist``的优先级高于``whitelist``。
只需用django shareddb变量替换对django的liveservertestcase的调用:
…代码块:python
from shareddb import testcases
class mytests(testcases.liveservertestcase):
def test_something(self):
但使用“django.test.testcase”而不是“django.test.transactiontestcase”。
在github上打开:https://github.com/rbarrois/django shareddb/issues
testing
----
>此库已通过sqlite和postgresql成功测试。
如果要使用其他数据库测试它,请克隆它并更改
``dev/settings.py``以安装程序,然后运行``./manage.py test``。