本文整理匯總了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)
示例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)
示例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)
示例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")
示例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
示例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)
示例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)
示例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)
示例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)
示例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__])
示例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)
示例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)
示例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")
示例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
示例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)