Changeset 7944
- Timestamp:
- 07/17/08 15:12:21 (4 months ago)
- Files:
-
- django/branches/newforms-admin (modified) (1 prop)
- django/branches/newforms-admin/django/db/models/query.py (modified) (1 diff)
- django/branches/newforms-admin/django/test/utils.py (modified) (1 diff)
- django/branches/newforms-admin/tests/regressiontests/admin_scripts/tests.py (modified) (1 diff)
- django/branches/newforms-admin/tests/regressiontests/queries/models.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/newforms-admin
- Property svnmerge-integrated changed from /django/trunk:1-4345,4350-4357,4359-4365,4371-4372,4374-4377,4380-4386,4388,4390-4391,4400-4402,4404-4408,4410,4412-4419,4426-4427,4430-4432,4434,4441,4443-4444,4446-4447,4450,4452-4453,4455-4458,4476,4503,4546,4564-4569,4580-4586,4617,4630,4641-6390,6392-7936 to /django/trunk:1-4345,4350-4357,4359-4365,4371-4372,4374-4377,4380-4386,4388,4390-4391,4400-4402,4404-4408,4410,4412-4419,4426-4427,4430-4432,4434,4441,4443-4444,4446-4447,4450,4452-4453,4455-4458,4476,4503,4546,4564-4569,4580-4586,4617,4630,4641-6390,6392-7943
django/branches/newforms-admin/django/db/models/query.py
r7922 r7944 281 281 integer. 282 282 283 If the QuerySet is already cached (i.e. self._result_cache is set) this 284 simply returns the length of the cached results set to avoid multiple 285 SELECT COUNT(*) calls. 286 """ 287 if self._result_cache is not None: 283 If the QuerySet is already fully cached this simply returns the length 284 of the cached results set to avoid multiple SELECT COUNT(*) calls. 285 """ 286 if self._result_cache is not None and not self._iter: 288 287 return len(self._result_cache) 289 288 django/branches/newforms-admin/django/test/utils.py
r6955 r7944 75 75 "Make sure a connection is in autocommit mode." 76 76 if hasattr(connection.connection, "autocommit"): 77 connection.connection.autocommit(True) 77 if callable(connection.connection.autocommit): 78 connection.connection.autocommit(True) 79 else: 80 connection.connection.autocommit = True 78 81 elif hasattr(connection.connection, "set_isolation_level"): 79 82 connection.connection.set_isolation_level(0) django/branches/newforms-admin/tests/regressiontests/admin_scripts/tests.py
r7922 r7944 109 109 def assertOutput(self, stream, msg): 110 110 "Utility assertion: assert that the given message exists in the output" 111 self. assertTrue(msg in stream, "'%s' does not match actual output text '%s'" % (msg, stream))111 self.failUnless(msg in stream, "'%s' does not match actual output text '%s'" % (msg, stream)) 112 112 113 113 ########################################################################## django/branches/newforms-admin/tests/regressiontests/queries/models.py
r7937 r7944 5 5 import datetime 6 6 import pickle 7 import sys 7 8 8 9 from django.db import models … … 483 484 >>> Cover.objects.all() 484 485 [<Cover: first>, <Cover: second>] 485 486 # If you're not careful, it's possible to introduce infinite loops via default487 # ordering on foreign keys in a cycle. We detect that.488 >>> LoopX.objects.all()489 Traceback (most recent call last):490 ...491 FieldError: Infinite loop caused by ordering.492 493 >>> LoopZ.objects.all()494 Traceback (most recent call last):495 ...496 FieldError: Infinite loop caused by ordering.497 498 # ... but you can still order in a non-recursive fashion amongst linked fields499 # (the previous test failed because the default ordering was recursive).500 >>> LoopX.objects.all().order_by('y__x__y__x__id')501 []502 486 503 487 # If the remote model does not have a default ordering, we order by its 'id' … … 831 815 ... if i > 10: break 832 816 817 Bug #7759 -- count should work with a partially read result set. 818 >>> count = Number.objects.count() 819 >>> qs = Number.objects.all() 820 >>> for obj in qs: 821 ... qs.count() == count 822 ... break 823 True 824 833 825 """} 834 826 827 # In Python 2.3, exceptions raised in __len__ are swallowed (Python issue 828 # 1242657), so these cases return an empty list, rather than raising an 829 # exception. Not a lot we can do about that, unfortunately, due to the way 830 # Python handles list() calls internally. Thus, we skip the tests for Python 831 # 2.3. 832 if sys.version_info >= (2, 4): 833 __test__["API_TESTS"] += """ 834 # If you're not careful, it's possible to introduce infinite loops via default 835 # ordering on foreign keys in a cycle. We detect that. 836 >>> LoopX.objects.all() 837 Traceback (most recent call last): 838 ... 839 FieldError: Infinite loop caused by ordering. 840 841 >>> LoopZ.objects.all() 842 Traceback (most recent call last): 843 ... 844 FieldError: Infinite loop caused by ordering. 845 846 # ... but you can still order in a non-recursive fashion amongst linked fields 847 # (the previous test failed because the default ordering was recursive). 848 >>> LoopX.objects.all().order_by('y__x__y__x__id') 849 [] 850 """
