문제

Here is the method:

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

I have no clue where to begin writing a test for something like this. It may seem simple, but I am a newb to Python. Thanks in advance for the help!

도움이 되었습니까?

해결책

Let me recommend you this Test Driven Django Tutorial

http://www.tdd-django-tutorial.com/

Truly amazing tutorial, go through it and you will be enlightened.

Let me add also this talk:

https://dstegelman-conf-notes.readthedocs.org/en/latest/conferences/pycon2012/saturday/testing.html

And this:

https://pycon-2012-notes.readthedocs.org/en/latest/testing_and_django.html

다른 팁

If you're using Django at all (and even if you're not), I would very highly recommend the following book (available for free online):

Test-Driven Development with Python

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top