1
我正試圖將django-lean安裝到我的應用程序中。如何反轉('opensearch')在shell中工作,但在測試中失敗?
開放式搜索用於我的應用程序應用程序。
我可以在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