Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
16a842b3
Kaydet (Commit)
16a842b3
authored
May 30, 2016
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Refs #26621 -- Added tests for admindocs.views.simplify_regex().
üst
995d09ea
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
4 deletions
+13
-4
views.py
django/contrib/admindocs/views.py
+3
-3
tests.py
tests/admin_docs/tests.py
+10
-1
No files found.
django/contrib/admindocs/views.py
Dosyayı görüntüle @
16a842b3
...
...
@@ -394,9 +394,9 @@ non_named_group_matcher = re.compile(r'\(.*?\)')
def
simplify_regex
(
pattern
):
"""
Clean up urlpattern regexes into something
somewhat readable by Mere Humans:
turns something like
"^(?P<sport_slug>
\
w+)/athletes/(?P<athlete_slug>
\
w+)/$"
into "
<sport_slug>/athletes/<athlete_slug>/"
Clean up urlpattern regexes into something
more readable by humans. For
example, turn
"^(?P<sport_slug>
\
w+)/athletes/(?P<athlete_slug>
\
w+)/$"
into "
/<sport_slug>/athletes/<athlete_slug>/".
"""
# handle named groups first
pattern
=
named_group_matcher
.
sub
(
lambda
m
:
m
.
group
(
1
),
pattern
)
...
...
tests/admin_docs/tests.py
Dosyayı görüntüle @
16a842b3
...
...
@@ -3,7 +3,7 @@ import unittest
from
django.conf
import
settings
from
django.contrib.admindocs
import
utils
from
django.contrib.admindocs.views
import
get_return_data_type
from
django.contrib.admindocs.views
import
get_return_data_type
,
simplify_regex
from
django.contrib.auth.models
import
User
from
django.contrib.sites.models
import
Site
from
django.test
import
TestCase
,
modify_settings
,
override_settings
...
...
@@ -123,6 +123,15 @@ class AdminDocViewTests(TestDataMixin, AdminDocsTestCase):
finally
:
utils
.
docutils_is_available
=
True
def
test_simplify_regex
(
self
):
tests
=
(
(
'^a'
,
'/a'
),
(
'^(?P<a>
\
w+)/b/(?P<c>
\
w+)/$'
,
'/<a>/b/<c>/'
),
(
'^(?P<a>
\
w+)/b/(?P<c>
\
w+)$'
,
'/<a>/b/<c>'
),
)
for
pattern
,
output
in
tests
:
self
.
assertEqual
(
simplify_regex
(
pattern
),
output
)
@override_settings
(
TEMPLATES
=
[{
'NAME'
:
'ONE'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment