- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我遇到了测试问题。这是我第一次编写测试,但遇到了问题。
我刚刚在我的应用 users
中创建了一个测试文件夹,以及用于测试 url 的 test_urls.py
。
当我输入时:
python manage.py 测试用户
它说:
Creating test database for alias 'default'... Got an error creating the test database: database "database_name" already exists
Type 'yes' if you would like to try deleting the test database 'database_name', or 'no' to cancel:
这是什么意思?如果我输入 yes 会怎样?我会丢失数据库中的所有数据吗?
最佳答案
测试时,Django 会创建一个测试数据库来处理,这样您的开发数据库就不会受到污染。错误消息表明 Django 正在尝试创建一个名为 "database_name"
的测试数据库,并且该数据库已经存在。您应该检查您正在使用的数据库软件的表,并检查 database_name
中的内容,它可能是错误创建的。
如果您键入 yes,数据库 database_name
将被删除并且您不太可能恢复数据。因此,请先尝试了解发生了什么。
您应该在settings.py
中设置测试数据库的名称。有一个特定的 TEST
dictionary在 DATABASE
设置中:
settings.py
...
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'USER': 'mydatabaseuser',
'NAME': 'mydatabase',
'TEST': {
'NAME': 'mytestdatabase',
},
},
}
...
默认情况下,前缀 test_
被添加到开发数据库的名称中。你应该检查你的 settings.py
来检查发生了什么。
来自docs :
The default test database names are created by prepending
test_
to the value of eachNAME
inDATABASES
. When using SQLite, the tests will use an in-memory database by default (i.e., the database will be created in memory, bypassing the filesystem entirely!). TheTEST
dictionary inDATABASES
offers a number of settings to configure your test database. For example, if you want to use a different database name, specify NAME in theTEST
dictionary for any given database inDATABASES
.
关于python - Django 测试 : Got an error creating the test database: database "database_name" already exists,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55685341/
我正在尝试找出这两个部分之间的区别,这似乎与 question 重复,但那里给出的答案并没有解释很多,所以我想要一个更详细和简洁的解释。 最佳答案 拆分是出于安全原因。默认情况下(过去仅在 -Wl,-
ELF 格式的 .got 和 .got.plt 部分有什么区别? 最佳答案 我之前的评论是对的: I think .got is for relocations regarding global 'v
我知道在典型的 ELF 二进制文件中,函数是通过过程链接表 (PLT) 调用的。函数的 PLT 条目通常包含到全局偏移表 (GOT) 条目的跳转。该条目将首先引用一些代码以将实际函数地址加载到 GOT
我知道在典型的 ELF 二进制文件中,函数是通过过程链接表 (PLT) 调用的。函数的 PLT 条目通常包含到全局偏移表 (GOT) 条目的跳转。该条目将首先引用一些代码以将实际函数地址加载到 GOT
我对 SICP 1.37 的迭代解决方案是 (define (con-frac n d k) (define (iter i result) (if (= 1 i) res
我正在尝试开始部署,但收到此错误 error: error validating "httpd-basic-deployment.yaml": error validating data: Valid
获取错误 ORA-00932: inconsistent datatypes: expected CHAR got NUMBER 00932. 00000 - "inconsistent dataty
我在没有全局偏移表的情况下编译多个 PIC 文件时遇到问题。 使用以下参数编译第一个文件 onefile.c 时,程序集不包含对 GOT 的引用: arm-none-eabi-gcc.exe firs
Your smiling at me is my daily dose of magic. 你嫣然的微笑是我每日享受到的魅力。 you hold a piece of me no matte
我是 Twilio 的新手。我正在尝试使用本教程将 SMS 转发到电子邮件地址: https://www.twilio.com/blog/2017/07/forward-incoming-sms-me
谁能帮我在 GWT 上创建离线 map ,我听说过 OpenLayers,但我没有找到任何源代码,你对此有什么想法吗?谢谢。 最佳答案 您将需要GWT-Openlayers Wrapper对于 Ope
我正在处理一些在编译为 PIC(位置无关代码)时速度变慢 70-80% 的代码,并且正在寻找缓解问题的方法。问题的很大一部分是 gcc 坚持在每个函数中插入以下内容: call __i686.get_
我编写了一个自定义 hamcrest 匹配器,用于检查列表中的文件是否已被复制。该列表可能很长(1000 个以上文件),因此如果缺少一个文件,我不希望匹配器打印出整个列表。 我可以为丢失的文件进行自定
我的意思是在模块中定义的非静态全局变量,而不是在外部。 为什么一定要通过GOT引用呢?为什么不使用相对地址?(因为.data 段中的全局变量和.text 段中的引用之间的距离是一个常量,它也是位置无关
当我在阅读时 http://eli.thegreenplace.net/2011/11/03/position-independent-code-pic-in-shared-libraries/#id
某些特定于平台的功能(例如 SSE 或 AVX)的可用性可以在运行时确定,如果不想为不同的功能编译和发布不同的对象,这将非常有用。 例如,以下代码允许我检查 AVX 并使用 gcc 进行编译,它提供了
我如何检查互联网连接是否成功(Wifi/3G/其他) 如果用户没有 Wifi 连接,我已经向用户显示错误,但我如何才能确保用户确实获得了 3G 连接如果他们希望在没有 Wifi 连接的情况下连接使用应
这是示例程序集文件,test.s .global main main: mov __progname@GOT, %eax // failed to compile mov __
mysqldump:得到错误:1449:使用锁表时指定为定义者的用户('root'@'192.200.1.16')不存在 请给出上述错误的解决方案。 最佳答案 最好使用第一个mysqldump和--s
前言:本篇为笔者学习极客时间《深入浅出计算机组成》过程中的部分疑问和解疑记录,因为这一块问题笔者学习过程中搜索所得答案较少,故留此博客。 1. 编译、链接和加载 我们知道,“C 语言代码 - 汇编代码
我是一名优秀的程序员,十分优秀!