我正在尝试将django-lean安装到我的应用程序中。
在我的应用App中使用了开放式搜索。
我可以在Python shell中反转('opensearch')。但是,在测试中,反向('opensearch')* NoReverseMatch:反向'opensearch',带参数'()'和关键字参数
In [47]: reverse('opensearch')
Out[47]: '/opensearch.xml'
In [48]: response = client.get('/opensearch.xml')
In [49]: response.status_code
Out[49]: 200
这是尝试从测试中执行相同操作,由pdb.set_trace()
停止No fixtures found.
> /usr/local/lib/python2.7/site-packages/django_lean-0.15-py2.7.egg/django_lean/experiments/tests/test_tags.py(72)doTestIntegration()
-> response = client.get("confirm_human") # this is where the Client can't find the url
(Pdb) reverse('opensearch')
*** NoReverseMatch: Reverse for 'opensearch' with arguments '()' and keyword arguments '{}' not found.
以下是来自urls.py的代码:
url(r'^opensearch\.xml$', app.meta.opensearch, name='opensearch'),
最后,这是失败测试的traceroute:
======================================================================
ERROR: testIntegrationWithRegisteredUser (django_lean.experiments.tests.test_tags.ExperimentTagsTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/django_lean-0.15-py2.7.egg/django_lean/experiments/tests/test_tags.py", line 55, in testIntegrationWithRegisteredUser
client_factory=create_registered_user_client)
File "/usr/local/lib/python2.7/site-packages/django_lean-0.15-py2.7.egg/django_lean/experiments/tests/test_tags.py", line 71, in doTestIntegration
response = client.get(confirm_human_url)
File "/usr/local/lib/python2.7/site-packages/Django-1.2.1-py2.7.egg/django/test/client.py", line 290, in get
response = self.request(**r)
File "/usr/local/lib/python2.7/site-packages/Django-1.2.1-py2.7.egg/django/test/client.py", line 230, in request
response = self.handler(environ)
File "/usr/local/lib/python2.7/site-packages/Django-1.2.1-py2.7.egg/django/test/client.py", line 74, in __call__
response = self.get_response(request)
File "/usr/local/lib/python2.7/site-packages/Django-1.2.1-py2.7.egg/django/core/handlers/base.py", line 142, in get_response
return self.handle_uncaught_exception(request, resolver, exc_info)
File "/usr/local/lib/python2.7/site-packages/Django-1.2.1-py2.7.egg/django/core/handlers/base.py", line 181, in handle_uncaught_exception
return callback(request, **param_dict)
File "/usr/local/lib/python2.7/site-packages/Django-1.2.1-py2.7.egg/django/views/defaults.py", line 24, in server_error
return http.HttpResponseServerError(t.render(Context({})))
File "/usr/local/lib/python2.7/site-packages/Django-1.2.1-py2.7.egg/django/template/__init__.py", line 173, in render
return self._render(context)
File "/usr/local/lib/python2.7/site-packages/Django-1.2.1-py2.7.egg/django/test/utils.py", line 29, in instrumented_test_render
return self.nodelist.render(context)
File "/usr/local/lib/python2.7/site-packages/Django-1.2.1-py2.7.egg/django/template/__init__.py", line 796, in render
bits.append(self.render_node(node, context))
File "/usr/local/lib/python2.7/site-packages/Django-1.2.1-py2.7.egg/django/template/__init__.py", line 809, in render_node
return node.render(context)
File "/usr/local/lib/python2.7/site-packages/Django-1.2.1-py2.7.egg/django/template/loader_tags.py", line 125, in render
return compiled_parent._render(context)
File "/usr/local/lib/python2.7/site-packages/Django-1.2.1-py2.7.egg/django/test/utils.py", line 29, in instrumented_test_render
return self.nodelist.render(context)
File "/usr/local/lib/python2.7/site-packages/Django-1.2.1-py2.7.egg/django/template/__init__.py", line 796, in render
bits.append(self.render_node(node, context))
File "/usr/local/lib/python2.7/site-packages/Django-1.2.1-py2.7.egg/django/template/__init__.py", line 809, in render_node
return node.render(context)
File "/usr/local/lib/python2.7/site-packages/Django-1.2.1-py2.7.egg/django/template/defaulttags.py", line 378, in render
raise e
NoReverseMatch: Reverse for 'opensearch' with arguments '()' and keyword arguments '{}' not found.
----------------------------------------------------------------------
Ran 1 test in 1736.834s
答案 0 :(得分:1)
看起来可能是Bug 11077。如果是这样,问题就是一个覆盖urlconf的TestCase,如this comment中所述:“问题在于django.contrib.auth和django-registration的测试都将其TestCase.urls设置为覆盖默认的URLConf。“