| 521 | |
| 522 | |
| 523 | def test_str(): |
| 524 | c = config.Config() |
| 525 | o = str(c) |
| 526 | |
| 527 | # match the first few lines, some different types, but don't go OTT |
| 528 | # to avoid needless test fails with changes |
| 529 | OUTPUT_MATCH = { |
| 530 | 'access_log_format': '%(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s"', |
| 531 | 'accesslog': 'None', |
| 532 | 'backlog': '2048', |
| 533 | 'bind': "['127.0.0.1:8000']", |
| 534 | 'capture_output': 'False', |
| 535 | 'child_exit': '<ChildExit.child_exit()>', |
| 536 | } |
| 537 | for i, line in enumerate(o.splitlines()): |
| 538 | m = re.match(r'^(\w+)\s+= ', line) |
| 539 | assert m, "Line {} didn't match expected format: {!r}".format(i, line) |
| 540 | |
| 541 | key = m.group(1) |
| 542 | try: |
| 543 | s = OUTPUT_MATCH.pop(key) |
| 544 | except KeyError: |
| 545 | continue |
| 546 | |
| 547 | line_re = r'^{}\s+= {}$'.format(key, re.escape(s)) |
| 548 | assert re.match(line_re, line), '{!r} != {!r}'.format(line_re, line) |
| 549 | |
| 550 | if not OUTPUT_MATCH: |
| 551 | break |
| 552 | else: |
| 553 | assert False, 'missing expected setting lines? {}'.format( |
| 554 | OUTPUT_MATCH.keys() |
| 555 | ) |
| 556 | |
| 557 | |
| 558 | # Tests for _get_default_control_socket |