当前位置: 首页>>代码示例>>Python>>正文


Python test_support.is_jython方法代码示例

本文整理汇总了Python中test.test_support.is_jython方法的典型用法代码示例。如果您正苦于以下问题:Python test_support.is_jython方法的具体用法?Python test_support.is_jython怎么用?Python test_support.is_jython使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在test.test_support的用法示例。


在下文中一共展示了test_support.is_jython方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: assertValid

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import is_jython [as 别名]
def assertValid(self, str, symbol='single'):
        '''succeed iff str is a valid piece of code'''
        if is_jython:
            code = compile_command(str, "<input>", symbol)
            self.assertTrue(code)
            if symbol == "single":
                d,r = {},{}
                saved_stdout = sys.stdout
                sys.stdout = cStringIO.StringIO()
                try:
                    exec code in d
                    exec compile(str,"<input>","single") in r
                finally:
                    sys.stdout = saved_stdout
            elif symbol == 'eval':
                ctx = {'a': 2}
                d = { 'value': eval(code,ctx) }
                r = { 'value': eval(str,ctx) }
            self.assertEqual(unify_callables(r),unify_callables(d))
        else:
            expected = compile(str, "<input>", symbol, PyCF_DONT_IMPLY_DEDENT)
            self.assertEqual(compile_command(str, "<input>", symbol), expected) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:24,代码来源:test_codeop.py

示例2: test_main

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import is_jython [as 别名]
def test_main():
    tests = [TraceTestCase,
             RaisingTraceFuncTestCase]

    if not test_support.is_jython:
        tests.append(JumpTestCase)
    else:
        del TraceTestCase.test_02_arigo
        del TraceTestCase.test_05_no_pop_tops
        del TraceTestCase.test_07_raise
        del TraceTestCase.test_09_settrace_and_raise
        del TraceTestCase.test_10_ireturn
        del TraceTestCase.test_11_tightloop
        del TraceTestCase.test_12_tighterloop
        del TraceTestCase.test_13_genexp
        del TraceTestCase.test_14_onliner_if
        del TraceTestCase.test_15_loops

    test_support.run_unittest(*tests) 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:21,代码来源:test_trace.py

示例3: test_main

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import is_jython [as 别名]
def test_main():
    tests = [
        cPickleTests,
        cPicklePicklerTests,
        cPickleListPicklerTests,
        cPickleFastPicklerTests
    ]
    if test_support.is_jython:
        # XXX: Jython doesn't support list based picklers
        tests.remove(cPickleListPicklerTests)
        # XXX: These don't cause exceptions on Jython
        del cPickleFastPicklerTests.test_recursive_list
        del cPickleFastPicklerTests.test_recursive_inst
        del cPickleFastPicklerTests.test_recursive_dict
        del cPickleFastPicklerTests.test_recursive_multi
    test_support.run_unittest(*tests) 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:18,代码来源:test_cpickle.py

示例4: test_setget_override

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import is_jython [as 别名]
def test_setget_override(self):
        if not test_support.is_jython:
            return

        # http://bugs.jython.org/issue600790
        class GoofyListMapThing(ArrayList):
            def __init__(self):
                self.silly = "Nothing"

            def __setitem__(self, key, element):
                self.silly = "spam"

            def __getitem__(self, key):
                self.silly = "eggs"

        glmt = GoofyListMapThing()
        glmt['my-key'] = String('el1')
        self.assertEquals(glmt.silly, "spam")
        glmt['my-key']
        self.assertEquals(glmt.silly, "eggs") 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:22,代码来源:test_list_jy.py

示例5: test_main

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import is_jython [as 别名]
def test_main(verbose=None):
    if test_support.is_jython:
        # XXX: CPython implementation details
        del EnumerateTestCase.test_tuple_reuse
        del TestReversed.test_len
        del TestReversed.test_xrange_optimization
    testclasses = (EnumerateTestCase, SubclassTestCase, TestEmpty, TestBig,
                   TestReversed)
    test_support.run_unittest(*testclasses)

    # verify reference counting
    import sys
    if verbose and hasattr(sys, "gettotalrefcount"):
        counts = [None] * 5
        for i in xrange(len(counts)):
            test_support.run_unittest(*testclasses)
            counts[i] = sys.gettotalrefcount()
        print counts 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:20,代码来源:test_enumerate.py

示例6: test_mode

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import is_jython [as 别名]
def test_mode(self):
        # mkdtemp creates directories with the proper mode
        if not has_stat:
            return            # ugh, can't use TestSkipped.
        if test_support.is_jython and not os._native_posix:
            # Java doesn't support stating files for permissions
            return

        dir = self.do_create()
        try:
            mode = stat.S_IMODE(os.stat(dir).st_mode)
            mode &= 0777 # Mask off sticky bits inherited from /tmp
            expected = 0700
            if (sys.platform in ('win32', 'os2emx', 'mac') or
                test_support.is_jython and os._name == 'nt'):
                # There's no distinction among 'user', 'group' and 'world';
                # replicate the 'user' bits.
                user = expected >> 6
                expected = user * (1 + 8 + 64)
            self.assertEqual(mode, expected)
        finally:
            os.rmdir(dir) 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:24,代码来源:test_tempfile.py

示例7: test_iadd

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import is_jython [as 别名]
def test_iadd(self):
        super(CommonTest, self).test_iadd()
        u = self.type2test([0, 1])
        u2 = u
        u += [2, 3]
        self.assert_(u is u2)

        u = self.type2test("spam")
        u += "eggs"
        self.assertEqual(u, self.type2test("spameggs"))

        if not test_support.is_jython:
            self.assertRaises(TypeError, u.__iadd__, None)
        else:
            import operator
            self.assertRaises(TypeError, operator.__iadd__, u, None) 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:18,代码来源:list_tests.py

示例8: test_long

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import is_jython [as 别名]
def test_long(self):
        for proto in protocols:
            # 256 bytes is where LONG4 begins.
            for nbits in 1, 8, 8*254, 8*255, 8*256, 8*257:
                nbase = 1L << nbits
                for npos in nbase-1, nbase, nbase+1:
                    for n in npos, -npos:
                        pickle = self.dumps(n, proto)
                        got = self.loads(pickle)
                        self.assertEqual(n, got)
        # Try a monster.  This is quadratic-time in protos 0 & 1, so don't
        # bother with those.
        if is_jython:#see http://jython.org/bugs/1754225
            return
        nbase = long("deadbeeffeedface", 16)
        nbase += nbase << 1000000
        for n in nbase, -nbase:
            p = self.dumps(n, 2)
            got = self.loads(p)
            self.assertEqual(n, got) 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:22,代码来源:pickletester.py

示例9: test_proxy_ref

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import is_jython [as 别名]
def test_proxy_ref(self):
        o = C()
        o.bar = 1
        ref1 = weakref.proxy(o, self.callback)
        ref2 = weakref.proxy(o, self.callback)
        del o

        def check(proxy):
            proxy.bar

        extra_collect()
        self.assertRaises(weakref.ReferenceError, check, ref1)
        self.assertRaises(weakref.ReferenceError, check, ref2)
        # XXX: CPython GC collects C() immediately. use ref1 instead on
        # Jython
        if test_support.is_jython:
            self.assertRaises(weakref.ReferenceError, bool, ref1)
        else:
            self.assertRaises(weakref.ReferenceError, bool, weakref.proxy(C()))
        self.assert_(self.cbcalled == 2) 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:22,代码来源:test_weakref.py

示例10: test_main

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import is_jython [as 别名]
def test_main():
    if test_support.is_jython:
        # Probably CPython GC specific (possibly even Jython bugs)
        del ReferencesTestCase.test_callback_in_cycle_resurrection
        del ReferencesTestCase.test_callbacks_on_callback

        # Jython allows types to be weakref'd that CPython doesn't
        del MappingTestCase.test_weak_keyed_bad_delitem

        # CPython GC specific
        del MappingTestCase.test_weak_keyed_cascading_deletes
    test_support.run_unittest(
        ReferencesTestCase,
        MappingTestCase,
        WeakValueDictionaryTestCase,
        WeakKeyDictionaryTestCase,
        )
    test_support.run_doctest(sys.modules[__name__]) 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:20,代码来源:test_weakref.py

示例11: test_expandtabs

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import is_jython [as 别名]
def test_expandtabs(self):
        self.checkequal('abc\rab      def\ng       hi', 'abc\rab\tdef\ng\thi', 'expandtabs')
        self.checkequal('abc\rab      def\ng       hi', 'abc\rab\tdef\ng\thi', 'expandtabs', 8)
        self.checkequal('abc\rab  def\ng   hi', 'abc\rab\tdef\ng\thi', 'expandtabs', 4)
        self.checkequal('abc\r\nab  def\ng   hi', 'abc\r\nab\tdef\ng\thi', 'expandtabs', 4)
        self.checkequal('abc\rab      def\ng       hi', 'abc\rab\tdef\ng\thi', 'expandtabs')
        self.checkequal('abc\rab      def\ng       hi', 'abc\rab\tdef\ng\thi', 'expandtabs', 8)
        self.checkequal('abc\r\nab\r\ndef\ng\r\nhi', 'abc\r\nab\r\ndef\ng\r\nhi', 'expandtabs', 4)
        self.checkequal('  a\n b', ' \ta\n\tb', 'expandtabs', 1)

        self.checkraises(TypeError, 'hello', 'expandtabs', 42, 42)
        # This test is only valid when sizeof(int) == sizeof(void*) == 4.

        # Jython uses a different algorithm for which overflows cannot occur;
        # but memory exhaustion of course can. So not applicable.
        if (sys.maxint < (1 << 32) and not test_support.is_jython
            and struct.calcsize('P') == 4):
            self.checkraises(OverflowError,
                             '\ta\n\tb', 'expandtabs', sys.maxint) 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:21,代码来源:string_tests.py

示例12: test_byteswap

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import is_jython [as 别名]
def test_byteswap(self):
        if test_support.is_jython and self.typecode == 'u':
            # Jython unicodes are already decoded from utf16,
            # so this doesn't make sense
            return
        a = array.array(self.typecode, self.example)
        self.assertRaises(TypeError, a.byteswap, 42)
        if a.itemsize in (1, 2, 4, 8):
            b = array.array(self.typecode, self.example)
            b.byteswap()
            if a.itemsize==1:
                self.assertEqual(a, b)
            else:
                self.assertNotEqual(a, b)
            b.byteswap()
            self.assertEqual(a, b) 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:18,代码来源:test_array.py

示例13: test_iadd

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import is_jython [as 别名]
def test_iadd(self):
        a = array.array(self.typecode, self.example[::-1])
        b = a
        a += array.array(self.typecode, 2*self.example)
        self.assert_(a is b)
        self.assertEqual(
            a,
            array.array(self.typecode, self.example[::-1]+2*self.example)
        )

        b = array.array(self.badtypecode())
        if test_support.is_jython:
            self.assertRaises(TypeError, operator.add, a, b)
            self.assertRaises(TypeError, operator.iadd, a, "bad")
        else:
            self.assertRaises(TypeError, a.__add__, b)
            self.assertRaises(TypeError, a.__iadd__, "bad") 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:19,代码来源:test_array.py

示例14: test_main

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import is_jython [as 别名]
def test_main(verbose=None):
    import sys

    if test_support.is_jython:
        # CPython specific; returns a memory address
        del BaseTest.test_buffer_info

        # No buffers in Jython
        del BaseTest.test_buffer

    test_support.run_unittest(*tests)

    # verify reference counting
    if verbose and hasattr(sys, "gettotalrefcount"):
        import gc
        counts = [None] * 5
        for i in xrange(len(counts)):
            test_support.run_unittest(*tests)
            gc.collect()
            counts[i] = sys.gettotalrefcount()
        print counts 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:23,代码来源:test_array.py

示例15: assertValid

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import is_jython [as 别名]
def assertValid(self, str, symbol='single'):
        '''succeed iff str is a valid piece of code'''
        if is_jython:
            code = compile_command(str, "<input>", symbol)
            self.assertTrue(code)
            if symbol == "single":
                d,r = {},{}
                saved_stdout = sys.stdout
                sys.stdout = cStringIO.StringIO()
                try:
                    exec code in d
                    exec compile(str,"<input>","single") in r
                finally:
                    sys.stdout = saved_stdout
            elif symbol == 'eval':
                ctx = {'a': 2}
                d = { 'value': eval(code,ctx) }
                r = { 'value': eval(str,ctx) }
            self.assertEquals(unify_callables(r),unify_callables(d))
        else:
            expected = compile(str, "<input>", symbol, PyCF_DONT_IMPLY_DEDENT)
            self.assertEquals( compile_command(str, "<input>", symbol), expected) 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:24,代码来源:test_codeop.py


注:本文中的test.test_support.is_jython方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。