(args=None)
| 535 | |
| 536 | |
| 537 | def test(args=None): |
| 538 | import sys |
| 539 | |
| 540 | if args is None: |
| 541 | args = sys.argv[1:] |
| 542 | |
| 543 | if args and args[0] == '-s': |
| 544 | args = args[1:] |
| 545 | klass = SGMLParser |
| 546 | else: |
| 547 | klass = TestSGMLParser |
| 548 | |
| 549 | if args: |
| 550 | file = args[0] |
| 551 | else: |
| 552 | file = 'test.html' |
| 553 | |
| 554 | if file == '-': |
| 555 | f = sys.stdin |
| 556 | else: |
| 557 | try: |
| 558 | f = open(file, 'r') |
| 559 | except IOError as msg: |
| 560 | print(file, ":", msg) |
| 561 | sys.exit(1) |
| 562 | |
| 563 | data = f.read() |
| 564 | if f is not sys.stdin: |
| 565 | f.close() |
| 566 | |
| 567 | x = klass() |
| 568 | for c in data: |
| 569 | x.feed(c) |
| 570 | x.close() |
| 571 | |
| 572 | |
| 573 | if __name__ == '__main__': |
no test coverage detected
searching dependent graphs…