comparison tests/test-check-help.t @ 41000:b6c610bf567e

py3: use bytes stdout in test-check-help.t Setting stdout to binary seemed to have no effect on Windows, as it was appending a literal '\r' to each topic keyword. This also stops prepending 'b' to the topic on all platforms as well.
author Matt Harbison <matt_harbison@yahoo.com>
date Tue, 18 Dec 2018 14:01:06 -0500
parents c36846abbcd3
children 42d2b31cee0b
comparison
equal deleted inserted replaced
40999:dcac24ec935b 41000:b6c610bf567e
8 > import sys 8 > import sys
9 > if sys.platform == "win32": 9 > if sys.platform == "win32":
10 > import msvcrt 10 > import msvcrt
11 > import os 11 > import os
12 > msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) 12 > msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
13 > stdout = getattr(sys.stdout, 'buffer', sys.stdout)
13 > topics = set() 14 > topics = set()
14 > topicre = re.compile(br':hg:`help ([a-z0-9\-.]+)`') 15 > topicre = re.compile(br':hg:`help ([a-z0-9\-.]+)`')
15 > for fname in sys.argv: 16 > for fname in sys.argv:
16 > with open(fname, 'rb') as f: 17 > with open(fname, 'rb') as f:
17 > topics.update(m.group(1) for m in topicre.finditer(f.read())) 18 > topics.update(m.group(1) for m in topicre.finditer(f.read()))
18 > for s in sorted(topics): 19 > for s in sorted(topics):
19 > print(s) 20 > stdout.write(b'%s\n' % s)
20 > EOF 21 > EOF
21 22
22 $ cd "$TESTDIR"/.. 23 $ cd "$TESTDIR"/..
23 24
24 Check if ":hg:`help TOPIC`" is valid: 25 Check if ":hg:`help TOPIC`" is valid: