def test_sgmlop_no_multiple_text_events():
	# Test that we don't get consecutive text events with sgmlop
	i = parse.events(parse.Iter(b"<a>gurk &amp; hurz &amp; hinz &amp; kunz</a>"), parse.SGMLOP())
	assert next(i) == ("url", url.URL("ITER"))
	assert next(i) == ("enterstarttag", "a")
	assert next(i) == ("leavestarttag", "a")
	assert next(i) == ("text", "gurk & hurz & hinz & kunz")
	assert next(i) == ("endtag", "a")
	with pytest.raises(StopIteration):
		next(i)
def test_expat_events_on_exception():
    # Test that all collected events are output before an exception is thrown
    i = parse.events(b"<x/>schrott", parse.Expat())
    assert next(i) == ("url", url.URL("STRING"))
    assert next(i) == ("position", (0, 0))
    assert next(i) == ("enterstarttag", "x")
    assert next(i) == ("leavestarttag", "x")
    assert next(i) == ("position", (0, 4))
    assert next(i) == ("endtag", "x")
    with pytest.raises(expat.ExpatError):
        next(i)
def test_expat_events_on_exception():
	# Test that all collected events are output before an exception is thrown
	i = parse.events(b"<x/>schrott", parse.Expat())
	assert next(i) == ("url", url.URL("STRING"))
	assert next(i) == ("position", (0, 0))
	assert next(i) == ("enterstarttag", "x")
	assert next(i) == ("leavestarttag", "x")
	assert next(i) == ("position", (0, 4))
	assert next(i) == ("endtag", "x")
	with pytest.raises(expat.ExpatError):
		next(i)
def test_sgmlop_no_multiple_text_events():
    # Test that we don't get consecutive text events with sgmlop
    i = parse.events(
        parse.Iter(b"<a>gurk &amp; hurz &amp; hinz &amp; kunz</a>"),
        parse.SGMLOP())
    assert next(i) == ("url", url.URL("ITER"))
    assert next(i) == ("enterstarttag", "a")
    assert next(i) == ("leavestarttag", "a")
    assert next(i) == ("text", "gurk & hurz & hinz & kunz")
    assert next(i) == ("endtag", "a")
    with pytest.raises(StopIteration):
        next(i)