<commit_before>import unittest

from django.test import TestCase

# In-case someone doesn't have Django REST Framework installed, guard tests.
try:
    from rest_framework import exceptions, filters
    from rest_framework.request import Request
    from rest_framework.test import APIRequestFactory

    factory = APIRequestFactory()

    from queryset_sequence.pagination import SequenceCursorPagination
except ImportError:
    factory = None

from queryset_sequence import QuerySetSequence

from tests.models import Author, Book, Publisher


class _TestPagination(SequenceCursorPagination):
    """A SequenceCursorPagination with a small page_size."""
    page_size = 5
    # The test models don't have a 'created' field.
    ordering = 'pages'


@unittest.skipIf(not factory, 'Must have Django REST Framework installed to run pagination tests.')
class TestSequenceCursorPagination(TestCase):
    """
    Unit tests for `queryset_sequence.pagination.SequenceCursorPagination`.

    Heavily based on `tests.test_pagination` from Django REST Framework.
    """

    PAGE_1 = [1, 2, 3, 4, 5]<commit_msg>Fix tests when DRF is not installed.<commit_after>import unittest

from django.test import TestCase

# In-case someone doesn't have Django REST Framework installed, guard tests.
try:
    from rest_framework import exceptions, filters
    from rest_framework.request import Request
    from rest_framework.test import APIRequestFactory

    factory = APIRequestFactory()

    from queryset_sequence.pagination import SequenceCursorPagination
except ImportError:
    factory = None
    SequenceCursorPagination = object

from queryset_sequence import QuerySetSequence

from tests.models import Author, Book, Publisher


class _TestPagination(SequenceCursorPagination):
    """A SequenceCursorPagination with a small page_size."""
    page_size = 5
    # The test models don't have a 'created' field.
    ordering = 'pages'


@unittest.skipIf(not factory, 'Must have Django REST Framework installed to run pagination tests.')
class TestSequenceCursorPagination(TestCase):
    """
    Unit tests for `queryset_sequence.pagination.SequenceCursorPagination`.

    Heavily based on `tests.test_pagination` from Django REST Framework.
    """

    PAGE_1 = [1, 2, 3, 4, 5]
{'fraction_non_alphanumeric': 0.06616674018526687, 'fraction_numerical': 0.0061755624172915745, 'mean_word_length': 4.518248175182482, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4978017', 'n_tokens_mistral': 634, 'n_tokens_neox': 597, 'n_words': 211}