<commit_before>import py.test
from sqlobject import *
from sqlobject.tests.dbtest import *


########################################
# Slicing tests
########################################


class Counter(SQLObject):

    number = IntCol(notNull=True)


class TestSlice:

    def setup_method(self, meth):
        setupClass(Counter)
        for i in range(100):
            Counter(number=i)

    def counterEqual(self, counters, value):
        if not supports('limitSelect'):
            py.test.skip("limitSelect isn't supported")
        assert [c.number for c in counters] == value

    def test_slice(self):
        self.counterEqual(
            Counter.select(None, orderBy='number'), range(100))

        self.counterEqual(
            Counter.select(None, orderBy='number')[10:20],
            range(10, 20))

        self.counterEqual(
            Counter.select(None, orderBy='number')[20:30][:5],
            range(20, 25))

        self.counterEqual(
            Counter.select(None, orderBy='number')[20:30][1:5],
            range(21, 25))

        self.counterEqual(
            Counter.select(None, orderBy='number')[:-10],
            range(0, 90))

        self.counterEqual(
            Counter.select(None, orderBy='number', reversed=True),
            range(99, -1, -1))

        self.counterEqual(
            Counter.select(None, orderBy='-number'),
            range(99, -1, -1))
<commit_msg>Ensure we have a list for slice tests in python 3<commit_after>import py.test
from sqlobject import *
from sqlobject.tests.dbtest import *


########################################
# Slicing tests
########################################


def listrange(*args):
    """Always return a list, for py3k compatibility"""
    return list(range(*args))


class Counter(SQLObject):

    number = IntCol(notNull=True)


class TestSlice:

    def setup_method(self, meth):
        setupClass(Counter)
        for i in range(100):
            Counter(number=i)

    def counterEqual(self, counters, value):
        if not supports('limitSelect'):
            py.test.skip("limitSelect isn't supported")
        assert [c.number for c in counters] == value

    def test_slice(self):
        self.counterEqual(
            Counter.select(None, orderBy='number'), listrange(100))

        self.counterEqual(
            Counter.select(None, orderBy='number')[10:20],
            listrange(10, 20))

        self.counterEqual(
            Counter.select(None, orderBy='number')[20:30][:5],
            listrange(20, 25))

        self.counterEqual(
            Counter.select(None, orderBy='number')[20:30][1:5],
            listrange(21, 25))

        self.counterEqual(
            Counter.select(None, orderBy='number')[:-10],
            listrange(0, 90))

        self.counterEqual(
            Counter.select(None, orderBy='number', reversed=True),
            listrange(99, -1, -1))

        self.counterEqual(
            Counter.select(None, orderBy='-number'),
            listrange(99, -1, -1))

{'fraction_non_alphanumeric': 0.1771144278606965, 'fraction_numerical': 0.031177446102819237, 'mean_word_length': 2.5069767441860464, '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': '6486031', 'n_tokens_mistral': 943, 'n_tokens_neox': 836, 'n_words': 183}