1#!/usr/bin/python -u 2import sys 3import libxml2 4 5# Memory debug specific 6libxml2.debugMemory(1) 7 8uri = libxml2.parseURI("http://example.org:8088/foo/bar?query=simple#fragid") 9if uri.scheme() != 'http': 10 print("Error parsing URI: wrong scheme") 11 sys.exit(1) 12if uri.server() != 'example.org': 13 print("Error parsing URI: wrong server") 14 sys.exit(1) 15if uri.port() != 8088: 16 print("Error parsing URI: wrong port") 17 sys.exit(1) 18if uri.path() != '/foo/bar': 19 print("Error parsing URI: wrong path") 20 sys.exit(1) 21if uri.query() != 'query=simple': 22 print("Error parsing URI: wrong query") 23 sys.exit(1) 24if uri.fragment() != 'fragid': 25 print("Error parsing URI: wrong query") 26 sys.exit(1) 27uri.setScheme("https") 28uri.setPort(223) 29uri.setFragment(None) 30result=uri.saveUri() 31if result != "https://example.org:223/foo/bar?query=simple": 32 print("Error modifying or saving the URI") 33uri = None 34 35# Memory debug specific 36libxml2.cleanupParser() 37if libxml2.debugMemory(1) == 0: 38 print("OK") 39else: 40 print("Memory leak %d bytes" % (libxml2.debugMemory(1))) 41 libxml2.dumpMemory() 42