()
| 398 | |
| 399 | |
| 400 | def test_socket(): |
| 401 | import socket |
| 402 | |
| 403 | def hook(event, args): |
| 404 | if event.startswith("socket."): |
| 405 | print(event, *args) |
| 406 | |
| 407 | sys.addaudithook(hook) |
| 408 | |
| 409 | socket.gethostname() |
| 410 | |
| 411 | # Don't care if this fails, we just want the audit message |
| 412 | sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) |
| 413 | try: |
| 414 | # Don't care if this fails, we just want the audit message |
| 415 | sock.bind(('127.0.0.1', 8080)) |
| 416 | except Exception: |
| 417 | pass |
| 418 | finally: |
| 419 | sock.close() |
| 420 | |
| 421 | |
| 422 | def test_gc(): |