mirror of https://github.com/django/django.git
26 lines
789 B
Python
26 lines
789 B
Python
|
from django.test import SimpleTestCase
|
||
|
from django.utils.hashable import make_hashable
|
||
|
|
||
|
|
||
|
class TestHashable(SimpleTestCase):
|
||
|
def test_equal(self):
|
||
|
tests = (
|
||
|
([], ()),
|
||
|
(['a', 1], ('a', 1)),
|
||
|
({}, ()),
|
||
|
({'a'}, {'a'}),
|
||
|
(frozenset({'a'}), {'a'}),
|
||
|
({'a': 1}, (('a', 1),)),
|
||
|
)
|
||
|
for value, expected in tests:
|
||
|
with self.subTest(value=value):
|
||
|
self.assertEqual(make_hashable(value), expected)
|
||
|
|
||
|
def test_count_equal(self):
|
||
|
tests = (
|
||
|
({'a': 1, 'b': ['a', 1]}, (('a', 1), ('b', ('a', 1)))),
|
||
|
)
|
||
|
for value, expected in tests:
|
||
|
with self.subTest(value=value):
|
||
|
self.assertCountEqual(make_hashable(value), expected)
|