summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRamiro Morales <cramm0@gmail.com>2013-06-28 22:38:13 -0300
committerRamiro Morales <cramm0@gmail.com>2013-06-28 22:38:13 -0300
commit7379d9aceab01e007966b5fe1f47ba7590deb887 (patch)
treea03857630a0074139af9a8c5311e6c6008fd461d
parent8eadbc5a03d06f5bfedfa3fad35ad0801d2ab6ff (diff)
Removed insert(), value_for_insert() SortedDict methods deprecated in Django 1.5.
-rw-r--r--django/utils/datastructures.py26
-rw-r--r--docs/ref/utils.txt14
-rw-r--r--tests/utils_tests/test_datastructures.py15
3 files changed, 0 insertions, 55 deletions
diff --git a/django/utils/datastructures.py b/django/utils/datastructures.py
index a211323320..3b1638392c 100644
--- a/django/utils/datastructures.py
+++ b/django/utils/datastructures.py
@@ -1,5 +1,4 @@
import copy
-import warnings
from django.utils import six
@@ -217,31 +216,6 @@ class SortedDict(dict):
self.keyOrder.append(key)
return super(SortedDict, self).setdefault(key, default)
- def value_for_index(self, index):
- """Returns the value of the item at the given zero-based index."""
- # This, and insert() are deprecated because they cannot be implemented
- # using collections.OrderedDict (Python 2.7 and up), which we'll
- # eventually switch to
- warnings.warn(
- "SortedDict.value_for_index is deprecated", DeprecationWarning,
- stacklevel=2
- )
- return self[self.keyOrder[index]]
-
- def insert(self, index, key, value):
- """Inserts the key, value pair before the item with the given index."""
- warnings.warn(
- "SortedDict.insert is deprecated", DeprecationWarning,
- stacklevel=2
- )
- if key in self.keyOrder:
- n = self.keyOrder.index(key)
- del self.keyOrder[n]
- if n < index:
- index -= 1
- self.keyOrder.insert(index, key)
- super(SortedDict, self).__setitem__(key, value)
-
def copy(self):
"""Returns a copy of this object."""
# This way of initializing the copy means it works for subclasses, too.
diff --git a/docs/ref/utils.txt b/docs/ref/utils.txt
index 8d722829fb..6fa829ef22 100644
--- a/docs/ref/utils.txt
+++ b/docs/ref/utils.txt
@@ -107,20 +107,6 @@ to distinguish caches by the ``Accept-language`` header.
The :class:`django.utils.datastructures.SortedDict` class is a dictionary
that keeps its keys in the order in which they're inserted.
- ``SortedDict`` adds two additional methods to the standard Python ``dict``
- class:
-
- .. method:: insert(index, key, value)
-
- .. deprecated:: 1.5
-
- Inserts the key, value pair before the item with the given index.
-
- .. method:: value_for_index(index)
-
- .. deprecated:: 1.5
-
- Returns the value of the item at the given zero-based index.
Creating a new SortedDict
-------------------------
diff --git a/tests/utils_tests/test_datastructures.py b/tests/utils_tests/test_datastructures.py
index 5829e7c2d7..5563a0fc4f 100644
--- a/tests/utils_tests/test_datastructures.py
+++ b/tests/utils_tests/test_datastructures.py
@@ -4,7 +4,6 @@ Tests for stuff in django.utils.datastructures.
import copy
import pickle
-import warnings
from django.test import SimpleTestCase
from django.utils.datastructures import (DictWrapper, ImmutableList,
@@ -134,20 +133,6 @@ class SortedDictTests(SimpleTestCase):
self.assertEqual(list(reversed(self.d1)), [9, 1, 7])
self.assertEqual(list(reversed(self.d2)), [7, 0, 9, 1])
- 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 DeprecationWarning
-
- 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 DeprecationWarning
-
class MergeDictTests(SimpleTestCase):