def test_track_changes_twice(porcusession):
    text = tkinter.Text(get_main_window())
    track_changes(text)
    with pytest.raises(
            RuntimeError,
            match=r'^track_changes\(\) called twice for same text widget$'):
        track_changes(text)
def test_track_changes_after_create_peer_widget(porcusession):
    text = tkinter.Text(get_main_window())
    peer = tkinter.Text(get_main_window())
    create_peer_widget(text, peer)
    with pytest.raises(
            RuntimeError,
            match=
            r'^track_changes\(\) must be called before create_peer_widget\(\)$'
    ):
        track_changes(text)
def text_and_events(porcusession):
    text = tkinter.Text(get_main_window())
    text.config(undo=True)  # must be before track_changes()
    track_changes(text)

    # peers can mess things up
    create_peer_widget(text, tkinter.Text(get_main_window()))

    events = []
    utils.bind_with_data(text, '<<ContentChanged>>', events.append, add=True)
    yield (text, events)
    assert not events