| 588 | return diff |
| 589 | |
| 590 | def test_timeout(url): |
| 591 | global DEBUG |
| 592 | dbbackup = DEBUG |
| 593 | class FakeLogger: |
| 594 | def debug(self, msg, *args): print(msg % args) |
| 595 | info = warning = error = debug |
| 596 | DEBUG = FakeLogger() |
| 597 | print(" fetching the file to establish a connection") |
| 598 | fo = _urllib.request.urlopen(url) |
| 599 | data1 = fo.read() |
| 600 | fo.close() |
| 601 | |
| 602 | i = 20 |
| 603 | print(" waiting %i seconds for the server to close the connection" % i) |
| 604 | while i > 0: |
| 605 | sys.stdout.write('\r %2i' % i) |
| 606 | sys.stdout.flush() |
| 607 | time.sleep(1) |
| 608 | i -= 1 |
| 609 | sys.stderr.write('\r') |
| 610 | |
| 611 | print(" fetching the file a second time") |
| 612 | fo = _urllib.request.urlopen(url) |
| 613 | data2 = fo.read() |
| 614 | fo.close() |
| 615 | |
| 616 | if data1 == data2: |
| 617 | print(' data are identical') |
| 618 | else: |
| 619 | print(' ERROR: DATA DIFFER') |
| 620 | |
| 621 | DEBUG = dbbackup |
| 622 | |
| 623 | |
| 624 | def test(url, N=10): |