0

我正在运行 Lettuce 内置服务器来测试它是否返回给定的响应,但是它显示了 500 响应。

我的功能文件:功能:主页加载

Scenario: Check that home page loads with header
  Given I access the home url
  then the home page should load with the title "Movies currently showing"

我的步骤文件:

@step(u'Given I access the home url')
  def given_i_access_the_home_url(step):
    world.response = world.browser.get(django_url('/'))
    sleep(10)


@step(u'then the home page should load with the title "([^"]*)"')
def then_the_home_page_should_load_with_the_title_group1(step, group1):
  assert group1 in world.response

我的地形文件:

from django.core.management import call_command
from django.test.simple import DjangoTestSuiteRunner

from lettuce import before, after, world
from logging import getLogger
from selenium import webdriver

try:
from south.management.commands import patch_for_test_db_setup
except:
pass

logger = getLogger(__name__)
logger.info("Loading the terrain file...")



@before.runserver
def setup_database(actual_server):
'''
This will setup your database, sync it, and run migrations if you are using South.
It does this before the Test Django server is set up.
'''
logger.info("Setting up a test database...")

# Uncomment if you are using South
# patch_for_test_db_setup()

world.test_runner = DjangoTestSuiteRunner(interactive=False)
DjangoTestSuiteRunner.setup_test_environment(world.test_runner)
world.created_db = DjangoTestSuiteRunner.setup_databases(world.test_runner)

call_command('syncdb', interactive=False, verbosity=0)

# Uncomment if you are using South
# call_command('migrate', interactive=False, verbosity=0)

@after.runserver
def teardown_database(actual_server):
'''
This will destroy your test database after all of your tests have executed.
'''
logger.info("Destroying the test database ...")

DjangoTestSuiteRunner.teardown_databases(world.test_runner, world.created_db)

@before.all
def setup_browser():
world.browser = webdriver.Firefox()

@after.all
def teardown_browser(total):
world.browser.quit()

服务器可能有什么问题,为什么会出现 500 响应错误?

4

1 回答 1

0

我设法找到了问题所在,迁移没有在 syncdb 上运行

于 2014-03-01T12:30:35.760 回答