def check_N(N, backend):
    with Display():
        ls = []
        try:
            for i in range(N):
                cmd = [
                    sys.executable,
                    __file__.rsplit(".", 1)[0] + ".py",
                    str(i),
                    backend,
                    "--debug",
                ]
                p = EasyProcess(cmd)
                p.start()
                ls += [p]

            sleep(3)

            good_count = 0
            rc_ls = []
            for p in ls:
                p.wait()
                if p.return_code == 0:
                    good_count += 1
                rc_ls += [p.return_code]
        finally:
            for p in ls:
                p.stop()
        print(rc_ls)
        print(good_count)
        assert good_count == N
Beispiel #2
0
def check_buttons(cmd, expect):
    with SmartDisplay(visible=VISIBLE) as disp:
        with EasyProcess(cmd):
            disp.waitgrab(timeout=TIMEOUT)
            buttons = discover_buttons()

            eq_(len(buttons), len(expect), 
                msg='dialog does not have expected buttons %s!=%s' % (buttons,expect))
            
            mouse = PyMouse()
            print 'buttons:',buttons
            for v, b in zip(expect, buttons):
                process = EasyProcess(cmd).start().sleep(1)
                mouse.click(*b.center)
                process.wait()
                eq_(process.stdout, str(v)) #dialog does not return expected value
Beispiel #3
0
    def test_timeout(self):
        p = EasyProcess('sleep 1').start()
        p.wait(0.2)
        eq_(p.is_alive(), True)
        p.wait(0.2)
        eq_(p.is_alive(), True)
        p.wait(2)
        eq_(p.is_alive(), False)

        eq_(EasyProcess('sleep 0.3').call().return_code == 0, True)
        eq_(EasyProcess('sleep 0.3').call(timeout=0.1).return_code == 0, False)
        eq_(EasyProcess('sleep 0.3').call(timeout=1).return_code == 0, True)

        eq_(EasyProcess('sleep 0.3').call().timeout_happened, False)
        eq_(EasyProcess('sleep 0.3').call(timeout=0.1).timeout_happened, True)
        eq_(EasyProcess('sleep 0.3').call(timeout=1).timeout_happened, False)
Beispiel #4
0
def test_timeout():
    p = EasyProcess("sleep 1").start()
    p.wait(0.2)
    assert p.is_alive()
    p.wait(0.2)
    assert p.is_alive()
    p.wait(2)
    assert not p.is_alive()

    assert EasyProcess("sleep 0.3").call().return_code == 0
    assert EasyProcess("sleep 0.3").call(timeout=0.1).return_code != 0
    assert EasyProcess("sleep 0.3").call(timeout=1).return_code == 0

    assert EasyProcess("sleep 0.3").call().timeout_happened is False
    assert EasyProcess("sleep 0.3").call(timeout=0.1).timeout_happened
    assert EasyProcess("sleep 0.3").call(timeout=1).timeout_happened is False
    def test_timeout(self):
        p = EasyProcess('sleep 1').start()
        p.wait(0.2)
        eq_(p.is_alive(), True)
        p.wait(0.2)
        eq_(p.is_alive(), True)
        p.wait(2)
        eq_(p.is_alive(), False)

        eq_(EasyProcess('sleep 0.3').call().return_code == 0, True)
        eq_(EasyProcess('sleep 0.3').call(timeout=0.1).return_code == 0, False)
        eq_(EasyProcess('sleep 0.3').call(timeout=1).return_code == 0, True)

        eq_(EasyProcess('sleep 0.3').call().timeout_happened, False)
        eq_(EasyProcess('sleep 0.3').call(timeout=0.1).timeout_happened, True)
        eq_(EasyProcess('sleep 0.3').call(timeout=1).timeout_happened, False)