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