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


Python test_support.vereq函数代码示例

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


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


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