Esempio n. 1
0
    def test_call_at(self, glib_loop):
        called = False

        def handler():
            nonlocal called
            called = True

            now = glib_loop.time()
            glib_loop.stop()

            assert now >= s + 1

        s = glib_loop.time()

        glib_loop.call_at(s+1, handler)
        glib_loop.run_forever()

        assert called, 'call_at handler didnt fire'
Esempio n. 2
0
    def test_call_at(self, glib_loop):
        called = False

        def handler():
            nonlocal called
            called = True

            now = glib_loop.time()
            glib_loop.stop()

            assert now >= s + 1

        s = glib_loop.time()

        glib_loop.call_at(s + 1, handler)
        glib_loop.run_forever()

        assert called, 'call_at handler didnt fire'
Esempio n. 3
0
    def test_call_at(self, glib_loop):
        called = False

        def handler():
            nonlocal called
            called = True

            now = glib_loop.time()
            glib_loop.stop()

            print(now, s)
            import math

            assert math.isclose(now, s, abs_tol=0.1)

        s = glib_loop.time()

        glib_loop.call_at(s + 0.1, handler)
        glib_loop.run_forever()

        assert called, "call_at handler didnt fire"
Esempio n. 4
0
 def test_call_at_no_coroutine(self, glib_loop):
     with pytest.raises(TypeError):
         glib_loop.call_at(1, no_op_coro)
Esempio n. 5
0
    def test_call_at_no_coroutine(self, glib_loop):
        async def coro():
            pass

        with pytest.raises(TypeError):
            glib_loop.call_at(1, coro)