我一直在尝试在django项目中启动并运行一组基本的Lettuce测试,但我遇到了一些问题。
我关注example tutorial on the lettuce website,但在运行python manage.py harvest
时出现以下错误:
Feature: Rocking with lettuce and django #apps/my_app/features/index.feature:1
Scenario: Simple Hello World # apps/my_app/features/index.feature:3
Given I access the url "/admin" # apps/my_app/features/index-steps.py:12
Given I access the url "/admin" # apps/my_app/features/index-steps.py:12
Traceback (most recent call last):
File "/home/myhome/.virtualenvs/my_env/lib/python2.7/site-packages/lettuce/core.py", line 141, in __call__
ret = self.function(self.step, *args, **kw)
File "/home/myhome/code/my_app/apps/my_app/features/index-steps.py", line 14, in access_url
world.dom = html.fromstring(response.content)
File "/home/myhome/.virtualenvs/my_env/lib/python2.7/site-packages/lxml/html/__init__.py", line 634, in fromstring
doc = document_fromstring(html, parser=parser, base_url=base_url, **kw)
File "/home/myhome/.virtualenvs/my_env/lib/python2.7/site-packages/lxml/html/__init__.py", line 532, in document_fromstring
value = etree.fromstring(html, parser, **kw)
File "lxml.etree.pyx", line 2756, in lxml.etree.fromstring (src/lxml/lxml.etree.c:54726)
File "parser.pxi", line 1578, in lxml.etree._parseMemoryDocument (src/lxml/lxml.etree.c:82843)
File "parser.pxi", line 1457, in lxml.etree._parseDoc (src/lxml/lxml.etree.c:81641)
File "parser.pxi", line 965, in lxml.etree._BaseParser._parseDoc (src/lxml/lxml.etree.c:78311)
File "parser.pxi", line 569, in lxml.etree._ParserContext._handleParseResultDoc (src/lxml/lxml.etree.c:74567)
File "parser.pxi", line 650, in lxml.etree._handleParseResult (src/lxml/lxml.etree.c:75458)
File "parser.pxi", line 601, in lxml.etree._raiseParseError (src/lxml/lxml.etree.c:74958)
XMLSyntaxError: None
Then I see the header "Log in | Django site admin" # apps/my_app/features/index-steps.py:17
Then I see the header "Log in | Django site admin" # apps/my_app/features/index-steps.py:17
1 feature (0 passed)
1 scenario (0 passed)
2 steps (1 failed, 1 skipped, 0 passed)
我在虚拟环境中安装了以下内容:
Django==1.4.1
MySQL-python==1.2.3
South==0.7.6
Werkzeug==0.8.3
boto==2.6.0
cssselect==0.7.1
django-extensions==0.9
django-nose==1.1
django-storages==1.1.5
django-tastypie==0.9.11
fuzzywuzzy==0.1
lettuce==0.2.10
lxml==2.3.5
mimeparse==0.1.3
mock==1.0.0
nose==1.2.1
python-dateutil==1.5
selenium==2.25.0
sure==1.0.6
wsgiref==0.1.2
这是一个错误,还是我在某个地方犯了一些错误?我原以为这个例子会涵盖它......
答案 0 :(得分:4)
显然,错误是红鲱鱼。我收到XMLSyntaxError
因为来自网址的响应为空(我检查的网址缺少一个尾部斜杠,在这种情况下)。
因此,如果有人遇到此问题,请在指责别人之前验证您自己的代码是否有效。