本文整理汇总了Python中test_support.verify函数的典型用法代码示例。如果您正苦于以下问题:Python verify函数的具体用法?Python verify怎么用?Python verify使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了verify函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_im_name
def test_im_name():
class C:
def foo(self): pass
verify(C.foo.__name__ == "foo")
verify(C().foo.__name__ == "foo")
cantset(C.foo, "__name__", "foo")
cantset(C().foo, "__name__", "foo")
开发者ID:denis-vilyuzhanin,项目名称:OpenModelSphereMirror,代码行数:7,代码来源:test_funcattrs.py
示例2: test_float_overflow
def test_float_overflow():
import math
if verbose:
print "long->float overflow"
for x in -2.0, -1.0, 0.0, 1.0, 2.0:
verify(float(long(x)) == x)
shuge = '12345' * 1000
huge = 1L << 30000
mhuge = -huge
namespace = {'huge': huge, 'mhuge': mhuge, 'shuge': shuge, 'math': math}
for test in ["float(huge)", "float(mhuge)",
"complex(huge)", "complex(mhuge)",
"complex(huge, 1)", "complex(mhuge, 1)",
"complex(1, huge)", "complex(1, mhuge)",
"1. + huge", "huge + 1.", "1. + mhuge", "mhuge + 1.",
"1. - huge", "huge - 1.", "1. - mhuge", "mhuge - 1.",
"1. * huge", "huge * 1.", "1. * mhuge", "mhuge * 1.",
"1. // huge", "huge // 1.", "1. // mhuge", "mhuge // 1.",
"1. / huge", "huge / 1.", "1. / mhuge", "mhuge / 1.",
"1. ** huge", "huge ** 1.", "1. ** mhuge", "mhuge ** 1.",
"math.sin(huge)", "math.sin(mhuge)",
"math.sqrt(huge)", "math.sqrt(mhuge)", # should do better
"math.floor(huge)", "math.floor(mhuge)",
"float(shuge) == long(shuge)"]:
try:
eval(test, namespace)
except OverflowError:
pass
else:
raise TestFailed("expected OverflowError from %s" % test)
开发者ID:doom38,项目名称:jython_v2.2.1,代码行数:34,代码来源:223_test_long.py
示例3: drive_one
def drive_one(pattern, length):
q, r = divmod(length, len(pattern))
teststring = pattern * q + pattern[:r]
verify(len(teststring) == length)
try_one(teststring)
try_one(teststring + "x")
try_one(teststring[:-1])
开发者ID:denis-vilyuzhanin,项目名称:OpenModelSphereMirror,代码行数:7,代码来源:test_bufio.py
示例4: check_all
def check_all(modname):
names = {}
try:
exec "import %s" % modname in names
except ImportError:
# Silent fail here seems the best route since some modules
# may not be available in all environments.
# Since an ImportError may leave a partial module object in
# sys.modules, get rid of that first. Here's what happens if
# you don't: importing pty fails on Windows because pty tries to
# import FCNTL, which doesn't exist. That raises an ImportError,
# caught here. It also leaves a partial pty module in sys.modules.
# So when test_pty is called later, the import of pty succeeds,
# but shouldn't. As a result, test_pty crashes with an
# AttributeError instead of an ImportError, and regrtest interprets
# the latter as a test failure (ImportError is treated as "test
# skipped" -- which is what test_pty should say on Windows).
try:
del sys.modules[modname]
except KeyError:
pass
return
verify(hasattr(sys.modules[modname], "__all__"),
"%s has no __all__ attribute" % modname)
names = {}
exec "from %s import *" % modname in names
if names.has_key("__builtins__"):
del names["__builtins__"]
keys = names.keys()
keys.sort()
all = list(sys.modules[modname].__all__) # in case it's a tuple
all.sort()
verify(keys==all, "%s != %s" % (keys, all))
开发者ID:denis-vilyuzhanin,项目名称:OpenModelSphereMirror,代码行数:33,代码来源:test___all__.py
示例5: test_logs
def test_logs():
import math
if verbose:
print "log and log10"
LOG10E = math.log10(math.e)
for exp in range(10) + [100, 1000, 10000]:
value = 10 ** exp
log10 = math.log10(value)
verify(fcmp(log10, exp) == 0)
# log10(value) == exp, so log(value) == log10(value)/log10(e) ==
# exp/LOG10E
expected = exp / LOG10E
log = math.log(value)
verify(fcmp(log, expected) == 0)
for bad in -(1L << 10000), -2L, 0L:
try:
math.log(bad)
raise TestFailed("expected ValueError from log(<= 0)")
except ValueError:
pass
try:
math.log10(bad)
raise TestFailed("expected ValueError from log10(<= 0)")
except ValueError:
pass
开发者ID:doom38,项目名称:jython_v2.2.1,代码行数:31,代码来源:223_test_long.py
示例6: test_im_doc
def test_im_doc():
class C:
def foo(self): "hello"
verify(C.foo.__doc__ == "hello")
verify(C().foo.__doc__ == "hello")
cantset(C.foo, "__doc__", "hello")
cantset(C().foo, "__doc__", "hello")
开发者ID:denis-vilyuzhanin,项目名称:OpenModelSphereMirror,代码行数:7,代码来源:test_funcattrs.py
示例7: test_im_class
def test_im_class():
class C:
def foo(self): pass
verify(C.foo.im_class is C)
verify(C().foo.im_class is C)
cantset(C.foo, "im_class", C)
cantset(C().foo, "im_class", C)
开发者ID:denis-vilyuzhanin,项目名称:OpenModelSphereMirror,代码行数:7,代码来源:test_funcattrs.py
示例8: test_im_self
def test_im_self():
class C:
def foo(self): pass
verify(C.foo.im_self is None)
c = C()
verify(c.foo.im_self is c)
cantset(C.foo, "im_self", None)
cantset(c.foo, "im_self", c)
开发者ID:denis-vilyuzhanin,项目名称:OpenModelSphereMirror,代码行数:8,代码来源:test_funcattrs.py
示例9: test_im_dict
def test_im_dict():
class C:
def foo(self): pass
foo.bar = 42
verify(C.foo.__dict__ == {'bar': 42})
verify(C().foo.__dict__ == {'bar': 42})
cantset(C.foo, "__dict__", C.foo.__dict__)
cantset(C().foo, "__dict__", C.foo.__dict__)
开发者ID:denis-vilyuzhanin,项目名称:OpenModelSphereMirror,代码行数:8,代码来源:test_funcattrs.py
示例10: test_func_code
def test_func_code():
def f(): pass
def g(): print 12
#XXX: changed to isinstance for jython
#verify(type(f.func_code) is types.CodeType)
verify(isinstance(f.func_code, types.CodeType))
f.func_code = g.func_code
cantset(f, "func_code", None)
开发者ID:denis-vilyuzhanin,项目名称:OpenModelSphereMirror,代码行数:8,代码来源:test_funcattrs.py
示例11: test_im_func
def test_im_func():
def foo(self): pass
class C:
pass
C.foo = foo
verify(C.foo.im_func is foo)
verify(C().foo.im_func is foo)
cantset(C.foo, "im_func", foo)
cantset(C().foo, "im_func", foo)
开发者ID:denis-vilyuzhanin,项目名称:OpenModelSphereMirror,代码行数:9,代码来源:test_funcattrs.py
示例12: testdgram
def testdgram(proto, addr):
s = socket.socket(proto, socket.SOCK_DGRAM)
s.sendto(teststring, addr)
buf = data = receive(s, 100)
while data and '\n' not in buf:
data = receive(s, 100)
buf += data
verify(buf == teststring)
s.close()
开发者ID:SMFOSS,项目名称:gevent,代码行数:9,代码来源:test_socketserver.py
示例13: teststream
def teststream(proto, addr):
s = socket.socket(proto, socket.SOCK_STREAM)
s.connect(addr)
s.sendall(teststring)
buf = data = receive(s, 100)
while data and '\n' not in buf:
data = receive(s, 100)
buf += data
verify(buf == teststring)
s.close()
开发者ID:SMFOSS,项目名称:gevent,代码行数:10,代码来源:test_socketserver.py
示例14: test
def test(openmethod, what):
if verbose:
print '\nTesting: ', what
fname = tempfile.mktemp()
f = openmethod(fname, 'c')
verify(f.keys() == [])
if verbose:
print 'creation...'
f['0'] = ''
f['a'] = 'Guido'
f['b'] = 'van'
f['c'] = 'Rossum'
f['d'] = 'invented'
f['f'] = 'Python'
if verbose:
print '%s %s %s' % (f['a'], f['b'], f['c'])
if what == 'BTree' :
if verbose:
print 'key ordering...'
f.set_location(f.first()[0])
while 1:
try:
rec = f.next()
except KeyError:
if rec != f.last():
print 'Error, last != last!'
f.previous()
break
if verbose:
print rec
if not f.has_key('a'):
print 'Error, missing key!'
f.sync()
f.close()
if verbose:
print 'modification...'
f = openmethod(fname, 'w')
f['d'] = 'discovered'
if verbose:
print 'access...'
for key in f.keys():
word = f[key]
if verbose:
print word
f.close()
try:
os.remove(fname)
except os.error:
pass
开发者ID:denis-vilyuzhanin,项目名称:OpenModelSphereMirror,代码行数:55,代码来源:test_bsddb.py
示例15: query_errors
def query_errors():
print "Testing query interface..."
cf = ConfigParser.ConfigParser()
verify(cf.sections() == [],
"new ConfigParser should have no defined sections")
verify(not cf.has_section("Foo"),
"new ConfigParser should have no acknowledged sections")
try:
cf.options("Foo")
except ConfigParser.NoSectionError, e:
pass
开发者ID:BackupTheBerlios,项目名称:etpe-svn,代码行数:11,代码来源:test_cfgparser.py
示例16: dicts
def dicts():
# Verify that __eq__ and __ne__ work for dicts even if the keys and
# values don't support anything other than __eq__ and __ne__. Complex
# numbers are a fine example of that.
import random
imag1a = {}
for i in range(50):
imag1a[random.randrange(100)*1j] = random.randrange(100)*1j
items = imag1a.items()
random.shuffle(items)
imag1b = {}
for k, v in items:
imag1b[k] = v
imag2 = imag1b.copy()
imag2[k] = v + 1.0
verify(imag1a == imag1a, "imag1a == imag1a should have worked")
verify(imag1a == imag1b, "imag1a == imag1b should have worked")
verify(imag2 == imag2, "imag2 == imag2 should have worked")
verify(imag1a != imag2, "imag1a != imag2 should have worked")
for op in "<", "<=", ">", ">=":
try:
eval("imag1a %s imag2" % op)
except TypeError:
pass
else:
raise TestFailed("expected TypeError from imag1a %s imag2" % op)
开发者ID:BackupTheBerlios,项目名称:etpe-svn,代码行数:26,代码来源:test_richcmp.py
示例17: __init__
def __init__(self, formatpair, bytesize):
assert len(formatpair) == 2
self.formatpair = formatpair
for direction in "<>!=":
for code in formatpair:
format = direction + code
verify(struct.calcsize(format) == bytesize)
self.bytesize = bytesize
self.bitsize = bytesize * 8
self.signed_code, self.unsigned_code = formatpair
self.unsigned_min = 0
self.unsigned_max = 2L**self.bitsize - 1
self.signed_min = -(2L**(self.bitsize-1))
self.signed_max = 2L**(self.bitsize-1) - 1
开发者ID:denis-vilyuzhanin,项目名称:OpenModelSphereMirror,代码行数:14,代码来源:test_struct.py
示例18: SimpleQueueTest
def SimpleQueueTest(q):
if not q.empty():
raise RuntimeError, "Call this function with an empty queue"
# I guess we better check things actually queue correctly a little :)
q.put(111)
q.put(222)
verify(q.get()==111 and q.get()==222, "Didn't seem to queue the correct data!")
for i in range(queue_size-1):
q.put(i)
verify(not q.full(), "Queue should not be full")
q.put("last")
verify(q.full(), "Queue should be full")
try:
q.put("full", block=0)
raise TestFailed("Didn't appear to block with a full queue")
except Queue.Full:
pass
# Test a blocking put
_doBlockingTest( q.put, ("full",), q.get, ())
# Empty it
for i in range(queue_size):
q.get()
verify(q.empty(), "Queue should be empty")
try:
q.get(block=0)
raise TestFailed("Didn't appear to block with an empty queue")
except Queue.Empty:
pass
# Test a blocking get
_doBlockingTest( q.get, (), q.put, ('empty',))
开发者ID:Bail-jw,项目名称:mediacomp-jes,代码行数:30,代码来源:test_queue.py
示例19: cantset
def cantset(obj, name, value):
verify(hasattr(obj, name)) # Otherwise it's probably a typo
try:
setattr(obj, name, value)
except (AttributeError, TypeError):
pass
else:
raise TestFailed, "shouldn't be able to set %s to %r" % (name, value)
try:
delattr(obj, name)
except (AttributeError, TypeError):
pass
else:
raise TestFailed, "shouldn't be able to del %s" % name
开发者ID:denis-vilyuzhanin,项目名称:OpenModelSphereMirror,代码行数:14,代码来源:test_funcattrs.py
示例20: write
def write(src):
print "Testing writing of files..."
cf = ConfigParser.ConfigParser()
sio = StringIO.StringIO(src)
cf.readfp(sio)
output = StringIO.StringIO()
cf.write(output)
verify(output, """[DEFAULT]
foo = another very
long line
[Long Line]
foo = this line is much, much longer than my editor
likes it.
""")
开发者ID:BackupTheBerlios,项目名称:etpe-svn,代码行数:15,代码来源:test_cfgparser.py
注:本文中的test_support.verify函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论