【问题标题】:Python: Lost writing a UnitTestPython:丢失了编写单元测试
【发布时间】:2014-03-13 23:55:54
【问题描述】:

方法如下:

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 的新手。提前感谢您的帮助!

【问题讨论】:

    标签: python django unit-testing python-unittest


    【解决方案1】:

    让我向你推荐这个测试驱动的 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

    【讨论】:

      【解决方案2】:

      如果您完全使用 Django(即使您没有使用),我强烈推荐以下书籍(可在线免费获得):

      Test-Driven Development with Python

      【讨论】:

        猜你喜欢
        • 2010-10-02
        • 1970-01-01
        • 1970-01-01
        • 2022-11-04
        • 2020-05-28
        • 1970-01-01
        • 2012-02-03
        • 2010-10-05
        相关资源
        最近更新 更多