1

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!

2 Answers 2

2

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

Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.