[Updated] D10637: tests: change the fixer commands to use the buffer attribute on stdio objects
mharbison72 (Matt Harbison)
phabricator at mercurial-scm.org
Thu May 6 17:21:26 UTC 2021
Closed by commit rHGea563187ee7c: tests: change the fixer commands to use the buffer attribute on stdio objects (authored by mharbison72).
This revision was automatically updated to reflect the committed changes.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D10637?vs=27676&id=27681
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D10637/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D10637
AFFECTED FILES
tests/test-fix-topology.t
tests/test-fix.t
CHANGE DETAILS
diff --git a/tests/test-fix.t b/tests/test-fix.t
--- a/tests/test-fix.t
+++ b/tests/test-fix.t
@@ -7,19 +7,21 @@
> from mercurial.utils.procutil import setbinary
> setbinary(sys.stdin)
> setbinary(sys.stdout)
+ > stdin = getattr(sys.stdin, 'buffer', sys.stdin)
+ > stdout = getattr(sys.stdout, 'buffer', sys.stdout)
> lines = set()
> for arg in sys.argv[1:]:
> if arg == 'all':
- > sys.stdout.write(sys.stdin.read().upper())
+ > stdout.write(stdin.read().upper())
> sys.exit(0)
> else:
> first, last = arg.split('-')
> lines.update(range(int(first), int(last) + 1))
- > for i, line in enumerate(sys.stdin.readlines()):
+ > for i, line in enumerate(stdin.readlines()):
> if i + 1 in lines:
- > sys.stdout.write(line.upper())
+ > stdout.write(line.upper())
> else:
- > sys.stdout.write(line)
+ > stdout.write(line)
> EOF
$ TESTLINES="foo\nbar\nbaz\nqux\n"
$ printf $TESTLINES | "$PYTHON" $UPPERCASEPY
diff --git a/tests/test-fix-topology.t b/tests/test-fix-topology.t
--- a/tests/test-fix-topology.t
+++ b/tests/test-fix-topology.t
@@ -6,7 +6,9 @@
> from mercurial.utils.procutil import setbinary
> setbinary(sys.stdin)
> setbinary(sys.stdout)
- > sys.stdout.write(sys.stdin.read().upper())
+ > stdin = getattr(sys.stdin, 'buffer', sys.stdin)
+ > stdout = getattr(sys.stdout, 'buffer', sys.stdout)
+ > stdout.write(stdin.read().upper())
> EOF
$ TESTLINES="foo\nbar\nbaz\n"
$ printf $TESTLINES | "$PYTHON" $UPPERCASEPY
To: mharbison72, #hg-reviewers, Alphare
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20210506/f27362e1/attachment-0002.html>
More information about the Mercurial-patches
mailing list