def test_graceful(bus, listener, log_tracker):
    """Test that bus graceful state triggers all listeners."""
    num = 3

    for index in range(num):
        bus.subscribe('graceful', listener.get_listener('graceful', index))

    bus.graceful()

    # The graceful method MUST call all 'graceful' listeners.
    assert set(listener.responses) == set(
        msg % (i, 'graceful', None) for i in range(num)
    )

    # The graceful method MUST log its states.
    assert log_tracker.log_entries == ['Bus graceful']
Test that bus graceful state triggers all listeners.
cherrypy/test/test_bus.py