diff options
| author | Marc Tamlyn <marc.tamlyn@gmail.com> | 2013-03-20 10:47:56 +0000 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2013-03-22 17:31:29 +0100 |
| commit | 829dc3c5a64d3fa203b8cc0055e83cf23addfee3 (patch) | |
| tree | 227c1b5aba3e785744863b269262c3c2c0c90ca8 /tests | |
| parent | f7795e968dd07323aa5bd16f9da0e60d97a75d0f (diff) | |
Fixed #20094 - Be more careful when checking for Iterator
Python 2.6 has some different behaviour when checking
isinstance(foo, collections.Iterator).
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/utils_tests/itercompat.py | 11 | ||||
| -rw-r--r-- | tests/utils_tests/models.py | 14 | ||||
| -rw-r--r-- | tests/utils_tests/tests.py | 1 |
3 files changed, 25 insertions, 1 deletions
diff --git a/tests/utils_tests/itercompat.py b/tests/utils_tests/itercompat.py new file mode 100644 index 0000000000..02d3463370 --- /dev/null +++ b/tests/utils_tests/itercompat.py @@ -0,0 +1,11 @@ +from django.test import TestCase + +from .models import Category, Thing + + +class TestIsIterator(TestCase): + def test_regression(self): + """This failed on Django 1.5/Py2.6 because category has a next method.""" + category = Category.objects.create(name='category') + Thing.objects.create(category=category) + Thing.objects.filter(category=category) diff --git a/tests/utils_tests/models.py b/tests/utils_tests/models.py index 97a72bab14..de8f9e3803 100644 --- a/tests/utils_tests/models.py +++ b/tests/utils_tests/models.py @@ -1 +1,13 @@ -# Test runner needs a models.py file. +from django.db import models + + +class Category(models.Model): + name = models.CharField(max_length=100) + + def next(self): + return self + + +class Thing(models.Model): + name = models.CharField(max_length=100) + category = models.ForeignKey(Category) diff --git a/tests/utils_tests/tests.py b/tests/utils_tests/tests.py index 726df3d979..f9c6e55847 100644 --- a/tests/utils_tests/tests.py +++ b/tests/utils_tests/tests.py @@ -18,6 +18,7 @@ from .feedgenerator import FeedgeneratorTest from .functional import FunctionalTestCase from .html import TestUtilsHtml from .http import TestUtilsHttp, ETagProcessingTests, HttpDateProcessingTests +from .itercompat import TestIsIterator from .ipv6 import TestUtilsIPv6 from .jslex import JsToCForGettextTest, JsTokensTest from .module_loading import (CustomLoader, DefaultLoader, EggLoader, |
