Python 无法识别Django环境变量
通过在上的教程,我发现使用环境变量时会出现错误。使用Django 1.11、Selenium 3和Python 3.6Python 无法识别Django环境变量,python,django,staging,Python,Django,Staging,通过在上的教程,我发现使用环境变量时会出现错误。使用Django 1.11、Selenium 3和Python 3.6 (py36) C:\testgoat\superlists>STAGING_SERVER=superlists-staging.ottg.eu python manage.py test functional_tests 'STAGING_SERVER' is not recognized as an internal or external command, opera
(py36) C:\testgoat\superlists>STAGING_SERVER=superlists-staging.ottg.eu python manage.py test functional_tests
'STAGING_SERVER' is not recognized as an internal or external command,
operable program or batch file.
如果我正确理解了本教程,将使用环境变量STAGING_SERVER
,使用真实服务器而不是Django的测试服务器运行测试
django.contrib.staticfiles.testing import StaticLiveServerTestCase
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.common.exceptions import WebDriverException
import time
import unittest
import sys
import os
MAX_WAIT = 10
class NewVisitorTest(StaticLiveServerTestCase):
def setUp(self):
self.browser = webdriver.Firefox()
staging_server = os.environ.get('STAGING_SERVER')
if staging_server:
setattr(self, 'live_server_url', 'http://' + staging_server)
[...]
Windows shell不支持这样的环境变量。它可以在bash之类的shell上工作,但不能在cmd上工作。有没有在Windows上执行此操作的等效方法?如果这意味着什么的话,我也会通过Anaconda运行它。请看这里:Windowsshell不支持这样的环境变量。它可以在bash之类的shell上工作,但不能在cmd上工作。有没有在Windows上执行此操作的等效方法?此外,如果这意味着什么的话,我正在通过Anaconda运行此程序。请参见此处: