'If UseForeignDTD is passed True and a document without an external
entity reference is parsed, ExternalEntityRefHandler is first called
with None for the public and system ids.'

def test_use_foreign_dtd(self):

    handler_call_args = []
    def resolve_entity(context, base, system_id, public_id):
        handler_call_args.append((public_id, system_id))
        return 1
    parser = expat.ParserCreate()
    parser.UseForeignDTD(True)
    parser.SetParamEntityParsing(expat.XML_PARAM_ENTITY_PARSING_ALWAYS)
    parser.ExternalEntityRefHandler = resolve_entity
    parser.Parse("<?xml    version='1.0'?><element/>")
    self.assertEqual(handler_call_args, [(None, None)])
    handler_call_args[:] = []
    parser = expat.ParserCreate()
    parser.UseForeignDTD()
    parser.SetParamEntityParsing(expat.XML_PARAM_ENTITY_PARSING_ALWAYS)
    parser.ExternalEntityRefHandler = resolve_entity
    parser.Parse("<?xml    version='1.0'?><element/>")
    self.assertEqual(handler_call_args, [(None, None)])
