Sha256: a033a1b12feac85314d4cf47421febe1953ea5cf5e190b0155cd10c80a2f7310

Contents?: true

Size: 1.58 KB

Versions: 30

Compression:

Stored size: 1.58 KB

Contents

"""Ensure longs passed to int arguments are handled correctly

Made for Jython.
"""
import array
import cStringIO
import tempfile
import test_support
import unittest
import StringIO

class LongIntArgsTestCase(unittest.TestCase):

    def test_array(self):
        a = array.array('c', 'jython')
        assert a.pop(0L) == 'j'

    def test_file(self):
        test_file = tempfile.TemporaryFile()
        try:
            self._test_file(test_file)
        finally:
            test_file.close()

    def test_StringIO(self):
        self._test_file(StringIO.StringIO())

    def test_cStringIO(self):
        self._test_file(cStringIO.StringIO())

    def test_str(self):
        self._test_basestring(str)

    def test_unicode(self):
        self._test_basestring(unicode)

    def _test_basestring(self, class_):
        s = class_('hello from jython')
        l = long(len(s))
        assert s.count('o', 0L, l) == 3
        assert s.endswith('n', 0L, l) == True
        assert s.expandtabs(1L) == s
        assert s.find('h', 0L, l) == 0
        assert s.index('h', 0L, l) == 0
        assert s.rfind('h', 0L, l) == 14
        assert s.rindex('h', 0L, l) == 14
        assert s.split(' ', 1L) == ['hello', 'from jython']
        assert s.startswith('jython', 11L)

    def _test_file(self, test_file):
        test_file.write('jython')
        test_file.seek(0L)
        assert test_file.read(1L) == 'j'
        assert test_file.readline(2L) == 'yt'
        assert test_file.readlines(3L) == ['hon']

def test_main():
    test_support.run_unittest(LongIntArgsTestCase)

if __name__ == '__main__':
    test_main()

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
rubyfox-server-2.19.2.0 lib/rubyfox/server/data/lib/Lib/test/test_long_int_args.py
rubyfox-server-2.17.3.2 lib/rubyfox/server/data/lib/Lib/test/test_long_int_args.py
rubyfox-server-2.17.3.1 lib/rubyfox/server/data/lib/Lib/test/test_long_int_args.py
rubyfox-server-2.17.3.0 lib/rubyfox/server/data/lib/Lib/test/test_long_int_args.py
rubyfox-server-2.16.3.2 lib/rubyfox/server/data/lib/Lib/test/test_long_int_args.py
rubyfox-server-2.16.3.1 lib/rubyfox/server/data/lib/Lib/test/test_long_int_args.py
rubyfox-server-2.16.0.4 lib/rubyfox/server/data/lib/Lib/test/test_long_int_args.py
rubyfox-server-2.16.0.3 lib/rubyfox/server/data/lib/Lib/test/test_long_int_args.py
rubyfox-server-2.16.0.2 lib/rubyfox/server/data/lib/Lib/test/test_long_int_args.py
rubyfox-server-2.16.0.1 lib/rubyfox/server/data/lib/Lib/test/test_long_int_args.py
rubyfox-server-2.16.0.0 lib/rubyfox/server/data/lib/Lib/test/test_long_int_args.py
rubyfox-server-2.13.7.3 lib/rubyfox/server/data/lib/Lib/test/test_long_int_args.py
rubyfox-server-2.13.6.2 lib/rubyfox/server/data/lib/Lib/test/test_long_int_args.py
rubyfox-server-2.13.6.1 lib/rubyfox/server/data/lib/Lib/test/test_long_int_args.py
rubyfox-server-2.13.5.1 lib/rubyfox/server/data/lib/Lib/test/test_long_int_args.py
rubyfox-server-2.13.4.1 lib/rubyfox/server/data/lib/Lib/test/test_long_int_args.py
rubyfox-server-2.13.3.1 lib/rubyfox/server/data/lib/Lib/test/test_long_int_args.py
rubyfox-server-2.12.5.1 lib/rubyfox/server/data/lib/Lib/test/test_long_int_args.py
rubyfox-server-2.12.5.0 lib/rubyfox/server/data/lib/Lib/test/test_long_int_args.py
rubyfox-server-2.12.4.0 lib/rubyfox/server/data/lib/Lib/test/test_long_int_args.py