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
38ce709f
Kaydet (Commit)
38ce709f
authored
Tem 24, 2012
tarafından
Alex Gaynor
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Added tests for deprecation warnings and fixed the argument order for the warnings.
üst
ae4125ff
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
4 deletions
+24
-4
datastructures.py
django/utils/datastructures.py
+8
-4
datastructures.py
tests/regressiontests/utils/datastructures.py
+16
-0
No files found.
django/utils/datastructures.py
Dosyayı görüntüle @
38ce709f
...
@@ -196,14 +196,18 @@ class SortedDict(dict):
...
@@ -196,14 +196,18 @@ class SortedDict(dict):
# This, and insert() are deprecated because they cannot be implemented
# This, and insert() are deprecated because they cannot be implemented
# using collections.OrderedDict (Python 2.7 and up), which we'll
# using collections.OrderedDict (Python 2.7 and up), which we'll
# eventually switch to
# eventually switch to
warnings
.
warn
(
PendingDeprecationWarning
,
warnings
.
warn
(
"SortedDict.value_for_index is deprecated"
,
stacklevel
=
2
)
"SortedDict.value_for_index is deprecated"
,
PendingDeprecationWarning
,
stacklevel
=
2
)
return
self
[
self
.
keyOrder
[
index
]]
return
self
[
self
.
keyOrder
[
index
]]
def
insert
(
self
,
index
,
key
,
value
):
def
insert
(
self
,
index
,
key
,
value
):
"""Inserts the key, value pair before the item with the given index."""
"""Inserts the key, value pair before the item with the given index."""
warnings
.
warn
(
PendingDeprecationWarning
,
warnings
.
warn
(
"SortedDict.insert is deprecated"
,
stacklevel
=
2
)
"SortedDict.insert is deprecated"
,
PendingDeprecationWarning
,
stacklevel
=
2
)
if
key
in
self
.
keyOrder
:
if
key
in
self
.
keyOrder
:
n
=
self
.
keyOrder
.
index
(
key
)
n
=
self
.
keyOrder
.
index
(
key
)
del
self
.
keyOrder
[
n
]
del
self
.
keyOrder
[
n
]
...
...
tests/regressiontests/utils/datastructures.py
Dosyayı görüntüle @
38ce709f
...
@@ -4,6 +4,7 @@ Tests for stuff in django.utils.datastructures.
...
@@ -4,6 +4,7 @@ Tests for stuff in django.utils.datastructures.
import
copy
import
copy
import
pickle
import
pickle
import
warnings
from
django.test
import
SimpleTestCase
from
django.test
import
SimpleTestCase
from
django.utils.datastructures
import
(
DictWrapper
,
ImmutableList
,
from
django.utils.datastructures
import
(
DictWrapper
,
ImmutableList
,
...
@@ -122,6 +123,21 @@ class SortedDictTests(SimpleTestCase):
...
@@ -122,6 +123,21 @@ class SortedDictTests(SimpleTestCase):
self
.
assertEqual
(
self
.
d1
,
{})
self
.
assertEqual
(
self
.
d1
,
{})
self
.
assertEqual
(
self
.
d1
.
keyOrder
,
[])
self
.
assertEqual
(
self
.
d1
.
keyOrder
,
[])
def
test_insert
(
self
):
d
=
SortedDict
()
with
warnings
.
catch_warnings
(
record
=
True
)
as
w
:
warnings
.
simplefilter
(
"always"
)
d
.
insert
(
0
,
"hello"
,
"world"
)
assert
w
[
0
]
.
category
is
PendingDeprecationWarning
def
test_value_for_index
(
self
):
d
=
SortedDict
({
"a"
:
3
})
with
warnings
.
catch_warnings
(
record
=
True
)
as
w
:
warnings
.
simplefilter
(
"always"
)
self
.
assertEqual
(
d
.
value_for_index
(
0
),
3
)
assert
w
[
0
]
.
category
is
PendingDeprecationWarning
class
MergeDictTests
(
SimpleTestCase
):
class
MergeDictTests
(
SimpleTestCase
):
def
test_simple_mergedict
(
self
):
def
test_simple_mergedict
(
self
):
...
...
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