Mercurial > hg
comparison tests/test-template-map.t @ 45055:4c1b4805db57
pycompat: change users of pycompat.{stdin,stdout,stderr} to use procutil.std*
On Python 3, pycompat.{stdin,stdout,stderr} are usually block-buffered even if
connected to a TTY. procutil.{stdin,stdout,stderr} provide consistent behavior
across platforms and Python versions.
author | Manuel Jacob <me@manueljacob.de> |
---|---|
date | Mon, 06 Jul 2020 17:44:25 +0200 |
parents | 829088e87032 |
children | db0be4678399 |
comparison
equal
deleted
inserted
replaced
45054:922dbf0df4f1 | 45055:4c1b4805db57 |
---|---|
673 | 673 |
674 $ cat <<'EOF' > "$TESTTMP/decodecborarray.py" | 674 $ cat <<'EOF' > "$TESTTMP/decodecborarray.py" |
675 > from __future__ import absolute_import | 675 > from __future__ import absolute_import |
676 > from mercurial import ( | 676 > from mercurial import ( |
677 > dispatch, | 677 > dispatch, |
678 > pycompat, | |
679 > ) | 678 > ) |
680 > from mercurial.utils import ( | 679 > from mercurial.utils import ( |
681 > cborutil, | 680 > cborutil, |
681 > procutil, | |
682 > stringutil, | 682 > stringutil, |
683 > ) | 683 > ) |
684 > dispatch.initstdio() | 684 > dispatch.initstdio() |
685 > data = pycompat.stdin.read() | 685 > data = procutil.stdin.read() |
686 > # our CBOR decoder doesn't support parsing indefinite-length arrays, | 686 > # our CBOR decoder doesn't support parsing indefinite-length arrays, |
687 > # but the log output is indefinite stream by nature. | 687 > # but the log output is indefinite stream by nature. |
688 > assert data[:1] == cborutil.BEGIN_INDEFINITE_ARRAY | 688 > assert data[:1] == cborutil.BEGIN_INDEFINITE_ARRAY |
689 > assert data[-1:] == cborutil.BREAK | 689 > assert data[-1:] == cborutil.BREAK |
690 > items = cborutil.decodeall(data[1:-1]) | 690 > items = cborutil.decodeall(data[1:-1]) |
691 > pycompat.stdout.write(stringutil.pprint(items, indent=1) + b'\n') | 691 > procutil.stdout.write(stringutil.pprint(items, indent=1) + b'\n') |
692 > EOF | 692 > EOF |
693 | 693 |
694 $ hg log -k nosuch -Tcbor | "$PYTHON" "$TESTTMP/decodecborarray.py" | 694 $ hg log -k nosuch -Tcbor | "$PYTHON" "$TESTTMP/decodecborarray.py" |
695 [] | 695 [] |
696 | 696 |