Details
Details
- Reviewers
- None
- Group Reviewers
hg-reviewers - Commits
- rHGc95c8ab2e7ec: tests: fix get-with-headers.py on python3 when writing to stdout
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
| hg-reviewers |
| Lint Skipped |
| Unit Tests Skipped |
| Path | Packages | |||
|---|---|---|---|---|
| M | tests/get-with-headers.py (2 lines) |
| print("%s: %s" % (h, response.getheader(h))) | print("%s: %s" % (h, response.getheader(h))) | ||||
| if not headeronly: | if not headeronly: | ||||
| print() | print() | ||||
| data = response.read() | data = response.read() | ||||
| if args.bodyfile: | if args.bodyfile: | ||||
| bodyfh = open(args.bodyfile, 'wb') | bodyfh = open(args.bodyfile, 'wb') | ||||
| else: | else: | ||||
| bodyfh = sys.stdout | bodyfh = getattr(sys.stdout, 'buffer', sys.stdout) | ||||
| # Pretty print JSON. This also has the beneficial side-effect | # Pretty print JSON. This also has the beneficial side-effect | ||||
| # of verifying emitted JSON is well-formed. | # of verifying emitted JSON is well-formed. | ||||
| if formatjson: | if formatjson: | ||||
| # json.dumps() will print trailing newlines. Eliminate them | # json.dumps() will print trailing newlines. Eliminate them | ||||
| # to make tests easier to write. | # to make tests easier to write. | ||||
| data = json.loads(data) | data = json.loads(data) | ||||
| lines = json.dumps(data, sort_keys=True, indent=2).splitlines() | lines = json.dumps(data, sort_keys=True, indent=2).splitlines() | ||||