##// END OF EJS Templates
tests: change the fixer commands to use the buffer attribute on stdio objects...
Matt Harbison -
r47862:ea563187 stable
parent child Browse files
Show More
@@ -6,7 +6,9 b' A script that implements uppercasing all'
6 6 > from mercurial.utils.procutil import setbinary
7 7 > setbinary(sys.stdin)
8 8 > setbinary(sys.stdout)
9 > sys.stdout.write(sys.stdin.read().upper())
9 > stdin = getattr(sys.stdin, 'buffer', sys.stdin)
10 > stdout = getattr(sys.stdout, 'buffer', sys.stdout)
11 > stdout.write(stdin.read().upper())
10 12 > EOF
11 13 $ TESTLINES="foo\nbar\nbaz\n"
12 14 $ printf $TESTLINES | "$PYTHON" $UPPERCASEPY
@@ -7,19 +7,21 b' approximates the behavior of code format'
7 7 > from mercurial.utils.procutil import setbinary
8 8 > setbinary(sys.stdin)
9 9 > setbinary(sys.stdout)
10 > stdin = getattr(sys.stdin, 'buffer', sys.stdin)
11 > stdout = getattr(sys.stdout, 'buffer', sys.stdout)
10 12 > lines = set()
11 13 > for arg in sys.argv[1:]:
12 14 > if arg == 'all':
13 > sys.stdout.write(sys.stdin.read().upper())
15 > stdout.write(stdin.read().upper())
14 16 > sys.exit(0)
15 17 > else:
16 18 > first, last = arg.split('-')
17 19 > lines.update(range(int(first), int(last) + 1))
18 > for i, line in enumerate(sys.stdin.readlines()):
20 > for i, line in enumerate(stdin.readlines()):
19 21 > if i + 1 in lines:
20 > sys.stdout.write(line.upper())
22 > stdout.write(line.upper())
21 23 > else:
22 > sys.stdout.write(line)
24 > stdout.write(line)
23 25 > EOF
24 26 $ TESTLINES="foo\nbar\nbaz\nqux\n"
25 27 $ printf $TESTLINES | "$PYTHON" $UPPERCASEPY
General Comments 0
You need to be logged in to leave comments. Login now