[Telepathy] twisted test question
alban.crequy at collabora.co.uk
Tue Jan 27 23:22:44 PST 2009
Le Tue, 27 Jan 2009 15:29:21 -0600,
Jonathon Jongsma <jonathon.jongsma at collabora.co.uk> a écrit :
> As many of you are aware, I'm adding some test cases to
> telepathy-idle. I have a decent feel for the test infrastructure
> now, but I don't see any way to assert that an event doesn't happen.
> For instance, if you want to assert that a dbus-signal is emitted,
> you can do things like:
> q.expect('dbus-signal', ...)
> but I don't see any way to specify that something shout NOT happen,
> maybe something like:
> q.expect_not('dbus-signal', ...)
> or perhaps more usefully, something like:
> that would require events 'foo' and 'bar' to happen but fail if event
> 'baz' occurs.
> Is there anything like that available? Has anybody wanted to do
> something similar and found a different way to achieve it?
You can have a look here:
You can register a callback when the dbus-signal is fired, and set up a
flag in the callback.
# Workaround to bug 9980: do not raise an error but use a flag
caps_changed_flag = True
Then you can assert your flag is False.
# don't receive any D-Bus signal
sync_dbus(bus, q, conn)
assert caps_changed_flag == False
It is not as easy as q.expect_not because you need some synchronisation
(sync_dbus...), and you cannot assert directly in the callback because
of bug #9980.
I am not sure 'ForbidEventPattern' is easy to write because you
would need to synchronise on possible events (D-Bus, streams).
More information about the Telepathy