方法如下:
def get_error_url(error_message, redirect_url=None):
error_url_parts = urlparse.urlsplit(redirect_url or settings.LANDING_PAGE_URL)
error_url = urlparse.urlunsplit(
(
error_url_parts.scheme,
error_url_parts.netloc,
error_url_parts.path,
urllib.urlencode([
('error', error_message),
]),
'',
)
)
return error_url
我不知道从哪里开始写这样的测试。这看起来很简单,但我是Python的新手。提前感谢您的帮助!你知道吗
让我向你推荐这个测试驱动的Django教程
http://www.tdd-django-tutorial.com/
真正了不起的教程,通过它,你会得到启发。你知道吗
我还要补充一点:
https://dstegelman-conf-notes.readthedocs.org/en/latest/conferences/pycon2012/saturday/testing.html
还有这个:
https://pycon-2012-notes.readthedocs.org/en/latest/testing_and_django.html
如果您使用的是Django(即使您没有),我强烈推荐以下书籍(可在网上免费获得):
Test-Driven Development with Python
相关问题 更多 >
编程相关推荐