def test_post(self):
# __doc__ (as of 2008-08-02) for pygame.fastevent.post:
# pygame.fastevent.post(Event) -> None
# place an event on the queue
#
# This will post your own event objects onto the event queue.
# You can past any event type you want, but some care must be
# taken. For example, if you post a MOUSEBUTTONDOWN event to the
# queue, it is likely any code receiving the event will expect
# the standard MOUSEBUTTONDOWN attributes to be available, like
# 'pos' and 'button'.
#
# Because pygame.fastevent.post() may have to wait for the queue
# to empty, you can get into a dead lock if you try to append an
# event on to a full queue from the thread that processes events.
# For that reason I do not recommend using this function in the
# main thread of an SDL program.
for _ in range(1, 11):
fastevent.post(event.Event(pygame.USEREVENT))
self.assertEquals (
[e.type for e in event.get()], [pygame.USEREVENT] * 10,
race_condition_notification
)
try:
# Special case for post: METH_O.
fastevent.post(1)
except TypeError:
e = geterror()
msg = ("argument 1 must be %s, not %s" %
(fastevent.Event.__name__, type(1).__name__))
self.failUnlessEqual(str(e), msg)
else:
self.fail()
评论列表
文章目录