'Subselects honor any manual ordering'

def test_ordered_subselect(self):

    try:
        query = DumbCategory.objects.filter(id__in=DumbCategory.objects.order_by(u'-id')[0:2])
        self.assertEqual(set(query.values_list(u'id', flat=True)), set([3, 4]))
        query = DumbCategory.objects.filter(id__in=DumbCategory.objects.order_by(u'-id')[:2])
        self.assertEqual(set(query.values_list(u'id', flat=True)), set([3, 4]))
        query = DumbCategory.objects.filter(id__in=DumbCategory.objects.order_by(u'-id')[1:2])
        self.assertEqual(set(query.values_list(u'id', flat=True)), set([3]))
        query = DumbCategory.objects.filter(id__in=DumbCategory.objects.order_by(u'-id')[2:])
        self.assertEqual(set(query.values_list(u'id', flat=True)), set([1, 2]))
    except DatabaseError as e:
        self.assertFalse(connections[DEFAULT_DB_ALIAS].features.allow_sliced_subqueries, str(e))
