mirror of
https://github.com/django/django.git
synced 2024-12-01 15:42:04 +01:00
5c1143910e
Should be unneeded with Python 2.7 and up. Added some unicode_literals along the way.
26 lines
929 B
Python
26 lines
929 B
Python
from django.test import TestCase
|
|
|
|
from .models import Guitarist
|
|
|
|
|
|
class PermalinkTests(TestCase):
|
|
urls = 'model_permalink.urls'
|
|
|
|
def test_permalink(self):
|
|
g = Guitarist(name='Adrien Moignard', slug='adrienmoignard')
|
|
self.assertEqual(g.url(), '/guitarists/adrienmoignard/')
|
|
|
|
def test_wrapped_docstring(self):
|
|
"Methods using the @permalink decorator retain their docstring."
|
|
g = Guitarist(name='Adrien Moignard', slug='adrienmoignard')
|
|
self.assertEqual(g.url.__doc__, "Returns the URL for this guitarist.")
|
|
|
|
def test_wrapped_attribute(self):
|
|
"""
|
|
Methods using the @permalink decorator can have attached attributes
|
|
from other decorators
|
|
"""
|
|
g = Guitarist(name='Adrien Moignard', slug='adrienmoignard')
|
|
self.assertTrue(hasattr(g.url_with_attribute, 'attribute'))
|
|
self.assertEqual(g.url_with_attribute.attribute, 'value')
|