##// 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 > from mercurial.utils.procutil import setbinary
6 > from mercurial.utils.procutil import setbinary
7 > setbinary(sys.stdin)
7 > setbinary(sys.stdin)
8 > setbinary(sys.stdout)
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 > EOF
12 > EOF
11 $ TESTLINES="foo\nbar\nbaz\n"
13 $ TESTLINES="foo\nbar\nbaz\n"
12 $ printf $TESTLINES | "$PYTHON" $UPPERCASEPY
14 $ printf $TESTLINES | "$PYTHON" $UPPERCASEPY
@@ -7,19 +7,21 b' approximates the behavior of code format'
7 > from mercurial.utils.procutil import setbinary
7 > from mercurial.utils.procutil import setbinary
8 > setbinary(sys.stdin)
8 > setbinary(sys.stdin)
9 > setbinary(sys.stdout)
9 > setbinary(sys.stdout)
10 > stdin = getattr(sys.stdin, 'buffer', sys.stdin)
11 > stdout = getattr(sys.stdout, 'buffer', sys.stdout)
10 > lines = set()
12 > lines = set()
11 > for arg in sys.argv[1:]:
13 > for arg in sys.argv[1:]:
12 > if arg == 'all':
14 > if arg == 'all':
13 > sys.stdout.write(sys.stdin.read().upper())
15 > stdout.write(stdin.read().upper())
14 > sys.exit(0)
16 > sys.exit(0)
15 > else:
17 > else:
16 > first, last = arg.split('-')
18 > first, last = arg.split('-')
17 > lines.update(range(int(first), int(last) + 1))
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 > if i + 1 in lines:
21 > if i + 1 in lines:
20 > sys.stdout.write(line.upper())
22 > stdout.write(line.upper())
21 > else:
23 > else:
22 > sys.stdout.write(line)
24 > stdout.write(line)
23 > EOF
25 > EOF
24 $ TESTLINES="foo\nbar\nbaz\nqux\n"
26 $ TESTLINES="foo\nbar\nbaz\nqux\n"
25 $ printf $TESTLINES | "$PYTHON" $UPPERCASEPY
27 $ printf $TESTLINES | "$PYTHON" $UPPERCASEPY
General Comments 0
You need to be logged in to leave comments. Login now