Commit f56fde4e by Alex Gaynor

Make sure we catch ordering errors where ordering is relevant.

parent 09649b88
...@@ -6,8 +6,12 @@ from taggit.tests.models import Food, Pet ...@@ -6,8 +6,12 @@ from taggit.tests.models import Food, Pet
class BaseTaggingTest(TestCase): class BaseTaggingTest(TestCase):
def assert_tags_equal(self, qs, tags): def assert_tags_equal(self, qs, tags, sort=True):
self.assertEqual(sorted(map(lambda tag: tag.name, qs)), sorted(list(tags))) got = map(lambda tag: tag.name, qs)
if sort:
got.sort()
tags.sort()
self.assertEqual(got, tags)
class AddTagTestCase(BaseTaggingTest): class AddTagTestCase(BaseTaggingTest):
...@@ -29,7 +33,7 @@ class AddTagTestCase(BaseTaggingTest): ...@@ -29,7 +33,7 @@ class AddTagTestCase(BaseTaggingTest):
self.assert_tags_equal(apple.tags.all(), ['green', 'red']) self.assert_tags_equal(apple.tags.all(), ['green', 'red'])
self.assert_tags_equal(Food.tags.all(), ['green', 'red']) self.assert_tags_equal(Food.tags.all(), ['green', 'red'])
self.assert_tags_equal(Food.tags.most_common(), ['green', 'red']) self.assert_tags_equal(Food.tags.most_common(), ['green', 'red'], sort=False)
apple.tags.remove('green') apple.tags.remove('green')
self.assert_tags_equal(apple.tags.all(), ['red']) self.assert_tags_equal(apple.tags.all(), ['red'])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment