コード例 #1
0
def loop_tests():
    global test_loop

    def tcheck_func():
        global loop_tchecks, loop_ichecks, verbose, test_loop
        loop_tchecks += 1
        if verbose:
            print "%s: %u" % ('tcheck_func', loop_tchecks)
        if loop_tchecks >= 10 and loop_ichecks >= 100:
            test_loop.quit()
        return True  # keep running

    def icheck_func():
        global loop_ichecks, verbose
        loop_ichecks += 1
        if verbose:
            print "%s: %u" % ('icheck_func', loop_ichecks)
        return True  # keep running

    test_loop = Rapicorn.MainLoop()
    ts = test_loop.exec_timer(tcheck_func, 0, 5)
    src = test_loop.exec_idle(icheck_func)
    test_loop.run()
    assert loop_tchecks >= 10 and loop_ichecks >= 100
コード例 #2
0
ファイル: t500-cython-core.py プロジェクト: ngeiswei/rapicorn
# Licensed CC0 Public Domain: http://creativecommons.org/publicdomain/zero/1.0
import Rapicorn  # @LINE_REWRITTEN_FOR_INSTALLCHECK@
import collections


# verify that pycallable() raises Exception
def assert_raises(Exception, pycallable, *args, **kwds):
    try:
        pycallable(*args, **kwds)
    except Exception:
        return
    raise AssertionError('%s not raised' % Exception.__name__)


# test MainLoop and EventLoop object identities
ml = Rapicorn.MainLoop()
sl = ml.create_sub_loop()
sm = sl.main_loop()
m3 = Rapicorn.MainLoop()
assert ml == ml and sl == sl and sm == sm and m3 == m3
assert ml != sl and sl != ml and sm != sl and sl != sm
assert ml == sm and sm == ml and ml != m3 and m3 != ml
assert ml.main_loop() == ml and m3.main_loop() == m3

# test exec_callback
ect_counter = 5
ect_value = ""


def bhandler():
    global ect_counter, ect_value