All Downloads are FREE. Search and download functionalities are using the official Maven repository.

Lib.test.test_enumerate_jy.py Maven / Gradle / Ivy

Go to download

Jython is an implementation of the high-level, dynamic, object-oriented language Python written in 100% Pure Java, and seamlessly integrated with the Java platform. It thus allows you to run Python on any Java platform.

There is a newer version: 2.7.4
Show newest version
import unittest
import sys

from test import test_support


class EnumerateJyTestCase(unittest.TestCase):

    enum = enumerate
    seq, start, res = 'abc', 5, [(5, 'a'), (6, 'b'), (7, 'c')]

    def test_start_kwarg_1(self):
        e = self.enum(self.seq, start=self.start)
        self.assertEqual(iter(e), e)
        self.assertEqual(list(e), self.res)

    def test_start_kwarg_2(self):
        e = self.enum(start=self.start, sequence=self.seq)
        self.assertEqual(iter(e), e)
        self.assertEqual(list(e), self.res)

    def test_start_pos(self):
        e = self.enum(self.seq, self.start)
        self.assertEqual(iter(e), e)
        self.assertEqual(list(e), self.res)

    def test_start_maxint(self):
        e = self.enum(self.seq, sys.maxint)
        self.assertEqual(list(e), [(2147483647, 'a'), (2147483648L, 'b'), (2147483649L, 'c')])


def test_main(verbose=None):
    testclasses = (EnumerateJyTestCase,)
    test_support.run_unittest(*testclasses)


if __name__ == "__main__":
    test_main(verbose=True)





© 2015 - 2024 Weber Informatics LLC | Privacy Policy