Question

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!

Was it helpful?

Solution

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

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top