diff options
| author | Gary Wilson Jr <gary.wilson@gmail.com> | 2008-07-02 04:31:28 +0000 |
|---|---|---|
| committer | Gary Wilson Jr <gary.wilson@gmail.com> | 2008-07-02 04:31:28 +0000 |
| commit | 54d50ef5c890242a8516346ea9ab97092c3fa8c1 (patch) | |
| tree | 7e89e37294e4c844d5c7185371f41cf9a0039124 /tests | |
| parent | bcb1c6dc7167039e715b3399bcc46cbeb5f2d8d1 (diff) | |
Made legacy `ObjectPaginator` truly backwards-compatible by catching both `AttributeError` and `TypeError` in `_get_count` as it did before
[7306]. Tests included.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@7819 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/modeltests/pagination/models.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/modeltests/pagination/models.py b/tests/modeltests/pagination/models.py index 277c5961e3..1f08a32903 100644 --- a/tests/modeltests/pagination/models.py +++ b/tests/modeltests/pagination/models.py @@ -200,6 +200,29 @@ InvalidPage: ... >>> paginator.page_range [1] +# ObjectPaginator can be passed lists too. +>>> paginator = ObjectPaginator([1, 2, 3], 5) +>>> paginator.hits +3 +>>> paginator.pages +1 +>>> paginator.page_range +[1] + + +# ObjectPaginator can be passed other objects with a count() method. +>>> class Container: +... def __len__(self): +... return 42 +>>> paginator = ObjectPaginator(Container(), 10) +>>> paginator.hits +42 +>>> paginator.pages +5 +>>> paginator.page_range +[1, 2, 3, 4, 5] + + ################## # Orphan support # ################## |
