为什么鼻子看不到我的任何环境变量?

编程入门 行业动态 更新时间:2024-10-28 06:21:58
本文介绍了为什么鼻子看不到我的任何环境变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我刚刚开始使用Nose和Nosetests,但由于鼻子看不到环境变量,所以我的测试失败了.

I'm just getting started using Nose and Nosetests and my tests are failing because Nose can't see the environmental variables.

到目前为止,这些错误: AttributeError:设置"对象没有属性"DJANGO_SETTINGS_MODULE"

So far, the errors: AttributeError: 'Settings' object has no attribute 'DJANGO_SETTINGS_MODULE'

我通过从.bash_profile中导出DJANGO_SETTINGS_MODULE来解决此问题

I fixed this by exporting DJANGO_SETTINGS_MODULE from .bash_profile

export DJANGO_SETTINGS_MODULE="settings"

现在我正在看到: AttributeError:设置"对象没有属性"DATABASE_SUPPORTS_TRANSACTIONS"

Now I'm seeing: AttributeError: 'Settings' object has no attribute 'DATABASE_SUPPORTS_TRANSACTIONS'

为什么iPython和Django网络服务器可以看到这些ENV变量,但鼻子看不到?

Why would iPython and the Django webserver be able to see these ENV variables, but Nose can't?

推荐答案

正如Alok所说,Nose不会从django.db.backends.creation调用BaseDatabaseCreation.create_test_db('None'),因此您需要设置此设置手动.

As Alok said, Nose doesn't call BaseDatabaseCreation.create_test_db('None') from django.db.backends.creation so you will need to set this setting manually.

我无法使它正常工作.

但是,我找到了NoseDjango.

However, I found NoseDjango.

使用以下命令安装NoseDjango:

Install NoseDjango with:

easy_install django-nose

由于django-nose扩展了Django的内置测试命令,因此应将其添加到settings.py中的INSTALLED_APPS中:

Since django-nose extends Django's built-in test command, you should add it to your INSTALLED_APPS in settings.py:

INSTALLED_APPS = ( ... 'django_nose', ... )

然后在settings.py中设置TEST_RUNNER:

Then set TEST_RUNNER in settings.py:

TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'

一旦设置了NoseDjango,您就可以通过以下方式运行您的Nose测试:

Once NoseDjango is setup you can run your Nose tests via:

manage.py test

更多推荐

为什么鼻子看不到我的任何环境变量?

本文发布于:2023-10-22 23:24:25,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1519037.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:环境变量   鼻子

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!