• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python test_support.vereq函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_2

def test_2():
    d = globals().copy()
    def testfunc():
        global x
        x = 1
    d['testfunc'] = testfunc
    profile.runctx("testfunc()", d, d, TESTFN)
    vereq (x, 1)
    os.unlink (TESTFN)
开发者ID:JupiterSmalltalk,项目名称:openqwaq,代码行数:9,代码来源:test_profile.py


示例2: test_anon

def test_anon():
    print "  anonymous mmap.mmap(-1, PAGESIZE)..."
    m = mmap.mmap(-1, PAGESIZE)
    for x in xrange(PAGESIZE):
        verify(m[x] == '\0', "anonymously mmap'ed contents should be zero")

    for x in xrange(PAGESIZE):
        m[x] = ch = chr(x & 255)
        vereq(m[x], ch)
开发者ID:Alex-CS,项目名称:sonify,代码行数:9,代码来源:test_mmap.py


示例3: test_3

def test_3():
    result = []
    def testfunc1():
        try: len(None)
        except: pass
        try: len(None)
        except: pass
        result.append(True)
    def testfunc2():
        testfunc1()
        testfunc1()
    profile.runctx("testfunc2()", locals(), locals(), TESTFN)
    vereq(result, [True, True])
    os.unlink(TESTFN)
开发者ID:JupiterSmalltalk,项目名称:openqwaq,代码行数:14,代码来源:test_profile.py


示例4: test_pack_into

def test_pack_into():
    test_string = 'Reykjavik rocks, eow!'
    writable_buf = array.array('c', ' '*100)
    fmt = '21s'
    s = struct.Struct(fmt)

    # Test without offset
    s.pack_into(writable_buf, 0, test_string)
    from_buf = writable_buf.tostring()[:len(test_string)]
    vereq(from_buf, test_string)

    # Test with offset.
    s.pack_into(writable_buf, 10, test_string)
    from_buf = writable_buf.tostring()[:len(test_string)+10]
    vereq(from_buf, test_string[:10] + test_string)

    # Go beyond boundaries.
    small_buf = array.array('c', ' '*10)
    assertRaises(struct.error, s.pack_into, small_buf, 0, test_string)
    assertRaises(struct.error, s.pack_into, small_buf, 2, test_string)
开发者ID:CONNJUR,项目名称:SparkyExtensions,代码行数:20,代码来源:test_struct.py


示例5: test_pack_into_fn

def test_pack_into_fn():
    test_string = 'Reykjavik rocks, eow!'
    writable_buf = array.array('c', ' '*100)
    fmt = '21s'
    pack_into = lambda *args: struct.pack_into(fmt, *args)

    # Test without offset.
    pack_into(writable_buf, 0, test_string)
    from_buf = writable_buf.tostring()[:len(test_string)]
    vereq(from_buf, test_string)

    # Test with offset.
    pack_into(writable_buf, 10, test_string)
    from_buf = writable_buf.tostring()[:len(test_string)+10]
    vereq(from_buf, test_string[:10] + test_string)

    # Go beyond boundaries.
    small_buf = array.array('c', ' '*10)
    assertRaises((struct.error, ValueError), pack_into, small_buf, 0, test_string)
    assertRaises((struct.error, ValueError), pack_into, small_buf, 2, test_string)
开发者ID:alkorzt,项目名称:pypy,代码行数:20,代码来源:test_struct.py


示例6: test_saveall

def test_saveall():
    # Verify that cyclic garbage like lists show up in gc.garbage if the
    # SAVEALL option is enabled.

    # First make sure we don't save away other stuff that just happens to
    # be waiting for collection.
    gc.collect()
    vereq(gc.garbage, []) # if this fails, someone else created immortal trash

    L = []
    L.append(L)
    id_L = id(L)

    debug = gc.get_debug()
    gc.set_debug(debug | gc.DEBUG_SAVEALL)
    del L
    gc.collect()
    gc.set_debug(debug)

    vereq(len(gc.garbage), 1)
    obj = gc.garbage.pop()
    vereq(id(obj), id_L)
开发者ID:bushuhui,项目名称:pyKanjiDict,代码行数:22,代码来源:test_gc.py


示例7: make_adder

warnings.filterwarnings("ignore", r"import \*", SyntaxWarning, "<string>")

print "1. simple nesting"


def make_adder(x):
    def adder(y):
        return x + y

    return adder


inc = make_adder(1)
plus10 = make_adder(10)

vereq(inc(1), 2)
vereq(plus10(-2), 8)

print "2. extra nesting"


def make_adder2(x):
    def extra():  # check freevars passing through non-use scopes
        def adder(y):
            return x + y

        return adder

    return extra()

开发者ID:alkorzt,项目名称:pypy,代码行数:29,代码来源:test_scope.py


示例8: checkfilename

def checkfilename(brokencode):
    try:
        _symtable.symtable(brokencode, "spam", "exec")
    except SyntaxError, e:
        vereq(e.filename, "spam")
开发者ID:facchinm,项目名称:SiRFLive,代码行数:5,代码来源:test_symtable.py


示例9: test_unpack_from

def test_unpack_from():
    test_string = 'abcd01234'
    fmt = '4s'
    s = struct.Struct(fmt)
    for cls in (str, buffer):
        data = cls(test_string)
        vereq(s.unpack_from(data), ('abcd',))
        vereq(s.unpack_from(data, 2), ('cd01',))
        vereq(s.unpack_from(data, 4), ('0123',))
        for i in xrange(6):
            vereq(s.unpack_from(data, i), (data[i:i+4],))
        for i in xrange(6, len(test_string) + 1):
            simple_err(s.unpack_from, data, i)
    for cls in (str, buffer):
        data = cls(test_string)
        vereq(struct.unpack_from(fmt, data), ('abcd',))
        vereq(struct.unpack_from(fmt, data, 2), ('cd01',))
        vereq(struct.unpack_from(fmt, data, 4), ('0123',))
        for i in xrange(6):
            vereq(struct.unpack_from(fmt, data, i), (data[i:i+4],))
        for i in xrange(6, len(test_string) + 1):
            simple_err(struct.unpack_from, fmt, data, i)
开发者ID:alkorzt,项目名称:pypy,代码行数:22,代码来源:test_struct.py


示例10: __str__

from test import test_support
import StringIO

# SF bug 480215:  softspace confused in nested print
f = StringIO.StringIO()
class C:
    def __str__(self):
        print >> f, 'a'
        return 'b'

print >> f, C(), 'c ', 'd\t', 'e'
print >> f, 'f', 'g'
# In 2.2 & earlier, this printed ' a\nbc  d\te\nf g\n'
test_support.vereq(f.getvalue(), 'a\nb c  d\te\nf g\n')
开发者ID:B-Rich,项目名称:breve,代码行数:14,代码来源:test_softspace.py


示例11: f

from test.test_support import vereq, TestFailed

import _symtable

symbols = _symtable.symtable("def f(x): return x", "?", "exec")

vereq(symbols[0].name, "global")
vereq(len([ste for ste in symbols.values() if ste.name == "f"]), 1)

# Bug tickler: SyntaxError file name correct whether error raised
# while parsing or building symbol table.
def checkfilename(brokencode):
    try:
        _symtable.symtable(brokencode, "spam", "exec")
    except SyntaxError, e:
        vereq(e.filename, "spam")
    else:
        raise TestFailed("no SyntaxError for %r" % (brokencode,))


checkfilename("def f(x): foo)(")  # parse-time
checkfilename("def f(x): global x")  # symtable-build-time
开发者ID:facchinm,项目名称:SiRFLive,代码行数:22,代码来源:test_symtable.py


示例12: f3

    pass


def f3(two, arguments):
    pass


def f4(two, (compound, (argument, list))):
    pass


def f5((compound, first), two):
    pass


vereq(f2.func_code.co_varnames, ("one_argument",))
vereq(f3.func_code.co_varnames, ("two", "arguments"))
if check_impl_detail(jython=True):
    vereq(f4.func_code.co_varnames, ("two", "(compound, (argument, list))", "compound", "argument", "list"))
    vereq(f5.func_code.co_varnames, ("(compound, first)", "two", "compound", "first"))
elif check_impl_detail(pypy=True):
    vereq(f4.func_code.co_varnames, ("two", ".2", "compound", "argument", "list"))
    vereq(f5.func_code.co_varnames, (".0", "two", "compound", "first"))
elif check_impl_detail(cpython=True):
    vereq(f4.func_code.co_varnames, ("two", ".1", "compound", "argument", "list"))
    vereq(f5.func_code.co_varnames, (".0", "two", "compound", "first"))


def a1(one_arg,):
    pass
开发者ID:AishwaryaKM,项目名称:python-tutorial,代码行数:30,代码来源:test_grammar.py


示例13: fpdef

### varargslist: (fpdef ['=' test] ',')* ('*' NAME [',' ('**'|'*' '*') NAME]
###            | ('**'|'*' '*') NAME)
###            | fpdef ['=' test] (',' fpdef ['=' test])* [',']
### fpdef: NAME | '(' fplist ')'
### fplist: fpdef (',' fpdef)* [',']
### arglist: (argument ',')* (argument | *' test [',' '**' test] | '**' test)
### argument: [test '='] test   # Really [keyword '='] test
def f1(): pass
f1()
f1(*())
f1(*(), **{})
def f2(one_argument): pass
def f3(two, arguments): pass
def f4(two, (compound, (argument, list))): pass
def f5((compound, first), two): pass
vereq(f2.func_code.co_varnames, ('one_argument',))
vereq(f3.func_code.co_varnames, ('two', 'arguments'))
if sys.platform.startswith('java'):
    vereq(f4.func_code.co_varnames,
           ('two', '(compound, (argument, list))', 'compound', 'argument',
                        'list',))
    vereq(f5.func_code.co_varnames,
           ('(compound, first)', 'two', 'compound', 'first'))
else:
    vereq(f4.func_code.co_varnames,
          ('two', '.1', 'compound', 'argument',  'list'))
    vereq(f5.func_code.co_varnames,
          ('.0', 'two', 'compound', 'first'))
def a1(one_arg,): pass
def a2(two, args,): pass
def v0(*rest): pass
开发者ID:SamuelKlein,项目名称:pspstacklesspython,代码行数:31,代码来源:test_grammar.py


示例14: file

atexit.register(handler1)
atexit.register(handler2)
atexit.register(handler2, 7, kw="abc")
"""

fname = TESTFN + ".py"
f = file(fname, "w")
f.write(input)
f.close()

p = popen('"%s" %s' % (executable, fname))
output = p.read()
p.close()
vereq(output, """\
handler2 (7,) {'kw': 'abc'}
handler2 () {}
handler1
""")

input = """\
def direct():
    print "direct exit"

import sys
sys.exitfunc = direct

# Make sure atexit doesn't drop
def indirect():
    print "indirect exit"

import atexit
开发者ID:OS2World,项目名称:APP-INTERNET-torpak_2,代码行数:31,代码来源:test_atexit.py


示例15: test_unpack_with_buffer

def test_unpack_with_buffer():
    # SF bug 1563759: struct.unpack doens't support buffer protocol objects
    data = array.array('B', '\x12\x34\x56\x78')
    value, = struct.unpack('>I', data)
    vereq(value, 0x12345678)
开发者ID:alkorzt,项目名称:pypy,代码行数:5,代码来源:test_struct.py


示例16: type

from test.test_support import verify, vereq, verbose, TestFailed

import sys
module = type(sys)

# An uninitialized module has no __dict__ or __name__, and __doc__ is None
foo = module.__new__(module)
verify(foo.__dict__ is None)
try:
    s = foo.__name__
except AttributeError:
    pass
else:
    raise TestFailed, "__name__ = %s" % repr(s)
vereq(foo.__doc__, module.__doc__)

# Regularly initialized module, no docstring
foo = module("foo")
vereq(foo.__name__, "foo")
vereq(foo.__doc__, None)
vereq(foo.__dict__, {"__name__": "foo", "__doc__": None})

# ASCII docstring
foo = module("foo", "foodoc")
vereq(foo.__name__, "foo")
vereq(foo.__doc__, "foodoc")
vereq(foo.__dict__, {"__name__": "foo", "__doc__": "foodoc"})

# Unicode docstring
foo = module("foo", u"foodoc\u1234")
开发者ID:B-Rich,项目名称:breve,代码行数:30,代码来源:test_module.py


示例17: test_both

def test_both():
    "Test mmap module on Unix systems and Windows"

    # Create a file to be mmap'ed.
    if os.path.exists(TESTFN):
        os.unlink(TESTFN)
    f = open(TESTFN, 'w+')

    try:    # unlink TESTFN no matter what
        # Write 2 pages worth of data to the file
        f.write('\0'* PAGESIZE)
        f.write('foo')
        f.write('\0'* (PAGESIZE-3) )
        f.flush()
        m = mmap.mmap(f.fileno(), 2 * PAGESIZE)
        f.close()

        # Simple sanity checks

        print type(m)  # SF bug 128713:  segfaulted on Linux
        print '  Position of foo:', m.find('foo') / float(PAGESIZE), 'pages'
        vereq(m.find('foo'), PAGESIZE)

        print '  Length of file:', len(m) / float(PAGESIZE), 'pages'
        vereq(len(m), 2*PAGESIZE)

        print '  Contents of byte 0:', repr(m[0])
        vereq(m[0], '\0')
        print '  Contents of first 3 bytes:', repr(m[0:3])
        vereq(m[0:3], '\0\0\0')

        # Modify the file's content
        print "\n  Modifying file's content..."
        m[0] = '3'
        m[PAGESIZE +3: PAGESIZE +3+3] = 'bar'

        # Check that the modification worked
        print '  Contents of byte 0:', repr(m[0])
        vereq(m[0], '3')
        print '  Contents of first 3 bytes:', repr(m[0:3])
        vereq(m[0:3], '3\0\0')
        print '  Contents of second page:',  repr(m[PAGESIZE-1 : PAGESIZE + 7])
        vereq(m[PAGESIZE-1 : PAGESIZE + 7], '\0foobar\0')

        m.flush()

        # Test doing a regular expression match in an mmap'ed file
        match = re.search('[A-Za-z]+', m)
        if match is None:
            print '  ERROR: regex match on mmap failed!'
        else:
            start, end = match.span(0)
            length = end - start

            print '  Regex match on mmap (page start, length of match):',
            print start / float(PAGESIZE), length

            vereq(start, PAGESIZE)
            vereq(end, PAGESIZE + 6)

        # test seeking around (try to overflow the seek implementation)
        m.seek(0,0)
        print '  Seek to zeroth byte'
        vereq(m.tell(), 0)
        m.seek(42,1)
        print '  Seek to 42nd byte'
        vereq(m.tell(), 42)
        m.seek(0,2)
        print '  Seek to last byte'
        vereq(m.tell(), len(m))

        print '  Try to seek to negative position...'
        try:
            m.seek(-1)
        except ValueError:
            pass
        else:
            verify(0, 'expected a ValueError but did not get it')

        print '  Try to seek beyond end of mmap...'
        try:
            m.seek(1,2)
        except ValueError:
            pass
        else:
            verify(0, 'expected a ValueError but did not get it')

        print '  Try to seek to negative position...'
        try:
            m.seek(-len(m)-1,2)
        except ValueError:
            pass
        else:
            verify(0, 'expected a ValueError but did not get it')

        # Try resizing map
        print '  Attempting resize()'
        try:
            m.resize(512)
        except SystemError:
#.........这里部分代码省略.........
开发者ID:Alex-CS,项目名称:sonify,代码行数:101,代码来源:test_mmap.py


示例18: test_issue4228

def test_issue4228():
    # Packing a long may yield either 32 or 64 bits
    x = struct.pack('L', -1)[:4]
    vereq(x, '\xff'*4)
开发者ID:abhijangda,项目名称:DacapoInputSets,代码行数:4,代码来源:test_struct.py


示例19: getattr

            os.kill(pid, getattr(signal, signame))
            print >> sys.__stdout__, "    child sent", signame, "to", pid
            time.sleep(1)
    finally:
        os._exit(0)

# Install handlers.
hup = signal.signal(signal.SIGHUP, handlerA)
usr1 = signal.signal(signal.SIGUSR1, handlerB)
usr2 = signal.signal(signal.SIGUSR2, signal.SIG_IGN)
alrm = signal.signal(signal.SIGALRM, signal.default_int_handler)

try:

    signal.alarm(MAX_DURATION)
    vereq(signal.getsignal(signal.SIGHUP), handlerA)
    vereq(signal.getsignal(signal.SIGUSR1), handlerB)
    vereq(signal.getsignal(signal.SIGUSR2), signal.SIG_IGN)
    vereq(signal.getsignal(signal.SIGALRM), signal.default_int_handler)

    # Try to ensure this test exits even if there is some problem with alarm.
    # Tru64/Alpha often hangs and is ultimately killed by the buildbot.
    fork_pid = force_test_exit()

    try:
        signal.getsignal(4242)
        raise TestFailed('expected ValueError for invalid signal # to '
                         'getsignal()')
    except ValueError:
        pass
开发者ID:B-Rich,项目名称:breve,代码行数:30,代码来源:test_signal.py


示例20: test_both

def test_both():
    "Test mmap module on Unix systems and Windows"

    # Create a file to be mmap'ed.
    if os.path.exists(TESTFN):
        os.unlink(TESTFN)
    f = open(TESTFN, "w+")

    try:  # unlink TESTFN no matter what
        # Write 2 pages worth of data to the file
        f.write("\0" * PAGESIZE)
        f.write("foo")
        f.write("\0" * (PAGESIZE - 3))
        f.flush()
        m = mmap.mmap(f.fileno(), 2 * PAGESIZE)
        f.close()

        # Simple sanity checks

        print type(m)  # SF bug 128713:  segfaulted on Linux
        print "  Position of foo:", m.find("foo") / float(PAGESIZE), "pages"
        vereq(m.find("foo"), PAGESIZE)

        print "  Length of file:", len(m) / float(PAGESIZE), "pages"
        vereq(len(m), 2 * PAGESIZE)

        print "  Contents of byte 0:", repr(m[0])
        vereq(m[0], "\0")
        print "  Contents of first 3 bytes:", repr(m[0:3])
        vereq(m[0:3], "\0\0\0")

        # Modify the file's content
        print "\n  Modifying file's content..."
        m[0] = "3"
        m[PAGESIZE + 3 : PAGESIZE + 3 + 3] = "bar"

        # Check that the modification worked
        print "  Contents of byte 0:", repr(m[0])
        vereq(m[0], "3")
        print "  Contents of first 3 bytes:", repr(m[0:3])
        vereq(m[0:3], "3\0\0")
        print "  Contents of second page:", repr(m[PAGESIZE - 1 : PAGESIZE + 7])
        vereq(m[PAGESIZE - 1 : PAGESIZE + 7], "\0foobar\0")

        m.flush()

        # Test doing a regular expression match in an mmap'ed file
        match = re.search("[A-Za-z]+", m)
        if match is None:
            print "  ERROR: regex match on mmap failed!"
        else:
            start, end = match.span(0)
            length = end - start

            print "  Regex match on mmap (page start, length of match):",
            print start / float(PAGESIZE), length

            vereq(start, PAGESIZE)
            vereq(end, PAGESIZE + 6)

        # test seeking around (try to overflow the seek implementation)
        m.seek(0, 0)
        print "  Seek to zeroth byte"
        vereq(m.tell(), 0)
        m.seek(42, 1)
        print "  Seek to 42nd byte"
        vereq(m.tell(), 42)
        m.seek(0, 2)
        print "  Seek to last byte"
        vereq(m.tell(), len(m))

        print "  Try to seek to negative position..."
        try:
            m.seek(-1)
        except ValueError:
            pass
        else:
            verify(0, "expected a ValueError but did not get it")

        print "  Try to seek beyond end of mmap..."
        try:
            m.seek(1, 2)
        except ValueError:
            pass
        else:
            verify(0, "expected a ValueError but did not get it")

        print "  Try to seek to negative position..."
        try:
            m.seek(-len(m) - 1, 2)
        except ValueError:
            pass
        else:
            verify(0, "expected a ValueError but did not get it")

        # Try resizing map
        print "  Attempting resize()"
        try:
            m.resize(512)
        except SystemError:
#.........这里部分代码省略.........
开发者ID:zhoupan,项目名称:OpenModelSphereMirror,代码行数:101,代码来源:test_mmap.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python test_support.verify函数代码示例发布时间:2022-05-27
下一篇:
Python test_support.unload函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap