django-rest-framework/tests/test_reverse.py
Andreas Pelme 971578ca34 Support for running the test suite with py.test
* Get rid of runtests.py
 * Moved test code  from rest_framework/tests and rest_framework/runtests to tests
 * Invoke py.test from setup.py
 * Invoke py.test from Travis
 * Invoke py.test from tox
 * Changed setUpClass to be just plain setUp in test_permissions.py
 * Updated contribution guideline to show how to invoke py.test
2014-03-02 12:40:30 +01:00

28 lines
688 B
Python

from __future__ import unicode_literals
from django.test import TestCase
from rest_framework.compat import patterns, url
from rest_framework.reverse import reverse
from rest_framework.test import APIRequestFactory
factory = APIRequestFactory()
def null_view(request):
pass
urlpatterns = patterns('',
url(r'^view$', null_view, name='view'),
)
class ReverseTests(TestCase):
"""
Tests for fully qualified URLs when using `reverse`.
"""
urls = 'tests.test_reverse'
def test_reversed_urls_are_fully_qualified(self):
request = factory.get('/view')
url = reverse('view', request=request)
self.assertEqual(url, 'http://testserver/view')