def test_map_error_handler():
    f = io.StringIO(SAMPLE_XML)

    def process_dump(dump, path, handle_error=lambda exp, stack: None):
        for page in dump:
            count = 0

            for rev in page:
                count += 1

            if count > 2:
                raise TypeError("Fake type error.")

            yield {'page_id': page.id, 'revisions': count}

    pages = 0
    for doc in map([f], process_dump):
        page_id = doc['page_id']
        revisions = doc['revisions']
        if page_id == 1:
            eq_(revisions, 2)
        elif page_id == 2:
            eq_(revisions, 1)
        else:
            assert False

        pages += 1

    eq_(pages, 2)
dataset/ETHPy150Open mediawiki-utilities/python-mediawiki-utilities/mw/xml_dump/tests/test_map.py/test_map_error_handler/original