mirror of
https://github.com/django/django.git
synced 2025-08-03 18:38:50 +00:00
Fixed #15604 -- Changed django.db.models.permalink to use wraps() so that it doesn't eat the docstring. Thanks for the report, sfllaw. Also added tests.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@15798 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
3a5b87cf6d
commit
72c5733869
5 changed files with 31 additions and 0 deletions
0
tests/regressiontests/model_permalink/__init__.py
Normal file
0
tests/regressiontests/model_permalink/__init__.py
Normal file
10
tests/regressiontests/model_permalink/models.py
Normal file
10
tests/regressiontests/model_permalink/models.py
Normal file
|
@ -0,0 +1,10 @@
|
|||
from django.db import models
|
||||
|
||||
class Guitarist(models.Model):
|
||||
name = models.CharField(max_length=50)
|
||||
slug = models.CharField(max_length=50)
|
||||
|
||||
@models.permalink
|
||||
def url(self):
|
||||
"Returns the URL for this guitarist."
|
||||
return ('guitarist_detail', [self.slug])
|
14
tests/regressiontests/model_permalink/tests.py
Normal file
14
tests/regressiontests/model_permalink/tests.py
Normal file
|
@ -0,0 +1,14 @@
|
|||
from django.test import TestCase
|
||||
from regressiontests.model_permalink.models import Guitarist
|
||||
|
||||
class PermalinkTests(TestCase):
|
||||
urls = 'regressiontests.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.")
|
5
tests/regressiontests/model_permalink/urls.py
Normal file
5
tests/regressiontests/model_permalink/urls.py
Normal file
|
@ -0,0 +1,5 @@
|
|||
from django.conf.urls.defaults import *
|
||||
|
||||
urlpatterns = patterns('',
|
||||
url(r'^guitarists/(\w{1,50})/$', 'unimplemented_view_placeholder', name='guitarist_detail'),
|
||||
)
|
Loading…
Add table
Add a link
Reference in a new issue