summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJoseph Kocherhans <joseph@jkocherhans.com>2006-05-28 21:27:07 +0000
committerJoseph Kocherhans <joseph@jkocherhans.com>2006-05-28 21:27:07 +0000
commitaeb807989f711c61b75c42241eea4c942becf19a (patch)
tree3a77e523f60b17e323b73677b7988da8f3f0ab11 /tests
parent681763a29c9d82858a214a6898e807be0c835c47 (diff)
multi-auth: Merged to [2997]
git-svn-id: http://code.djangoproject.com/svn/django/branches/multi-auth@2998 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
-rw-r--r--tests/modeltests/basic/models.py10
-rw-r--r--tests/modeltests/or_lookups/models.py4
-rw-r--r--tests/modeltests/ordering/models.py4
-rwxr-xr-xtests/runtests.py13
4 files changed, 30 insertions, 1 deletions
diff --git a/tests/modeltests/basic/models.py b/tests/modeltests/basic/models.py
index 0470d6bc9b..f60c3777e7 100644
--- a/tests/modeltests/basic/models.py
+++ b/tests/modeltests/basic/models.py
@@ -283,6 +283,16 @@ Traceback (most recent call last):
...
AssertionError: Cannot combine queries once a slice has been taken.
+# Negative slices are not supported, due to database constraints.
+# (hint: inverting your ordering might do what you need).
+>>> Article.objects.all()[-1]
+Traceback (most recent call last):
+ ...
+AssertionError: Negative indexing is not supported.
+>>> Article.objects.all()[0:-5]
+Traceback (most recent call last):
+ ...
+AssertionError: Negative indexing is not supported.
# An Article instance doesn't have access to the "objects" attribute.
# That's only available on the class.
diff --git a/tests/modeltests/or_lookups/models.py b/tests/modeltests/or_lookups/models.py
index a07dacdd5a..ef4d4dc5ca 100644
--- a/tests/modeltests/or_lookups/models.py
+++ b/tests/modeltests/or_lookups/models.py
@@ -89,6 +89,10 @@ Hello and goodbye
>>> Article.objects.filter(Q(headline__startswith='Hello')).in_bulk([1,2])
{1: Hello}
+# Demonstrating exclude with a Q object
+>>> Article.objects.exclude(Q(headline__startswith='Hello'))
+[Goodbye]
+
# The 'complex_filter' method supports framework features such as
# 'limit_choices_to' which normally take a single dictionary of lookup arguments
# but need to support arbitrary queries via Q objects too.
diff --git a/tests/modeltests/ordering/models.py b/tests/modeltests/ordering/models.py
index de08a75755..8b56731c55 100644
--- a/tests/modeltests/ordering/models.py
+++ b/tests/modeltests/ordering/models.py
@@ -56,6 +56,10 @@ API_TESTS = """
>>> Article.objects.order_by('headline')[1:3]
[Article 2, Article 3]
+# Getting a single item should work too:
+>>> Article.objects.all()[0]
+Article 4
+
# Use '?' to order randomly. (We're using [...] in the output to indicate we
# don't know what order the output will be in.
>>> Article.objects.order_by('?')
diff --git a/tests/runtests.py b/tests/runtests.py
index 32f893e1ea..f0eee97ec5 100755
--- a/tests/runtests.py
+++ b/tests/runtests.py
@@ -20,6 +20,17 @@ def log_error(model_name, title, description):
MODEL_TEST_DIR = os.path.join(os.path.dirname(__file__), MODEL_TESTS_DIR_NAME)
+ALWAYS_INSTALLED_APPS = [
+ 'django.contrib.admin',
+ 'django.contrib.auth',
+ 'django.contrib.comments',
+ 'django.contrib.contenttypes',
+ 'django.contrib.flatpages',
+ 'django.contrib.redirects',
+ 'django.contrib.sessions',
+ 'django.contrib.sites',
+]
+
def get_test_models():
return [f for f in os.listdir(MODEL_TEST_DIR) if not f.startswith('__init__') and not f.startswith('.')]
@@ -78,7 +89,7 @@ class TestRunner:
settings.INSTALLED_APPS
# Manually set INSTALLED_APPS to point to the test models.
- settings.INSTALLED_APPS = [MODEL_TESTS_DIR_NAME + '.' + a for a in get_test_models()]
+ settings.INSTALLED_APPS = ALWAYS_INSTALLED_APPS + [MODEL_TESTS_DIR_NAME + '.' + a for a in get_test_models()]
# Manually set DEBUG = False.
settings.DEBUG = False