Mercurial > hg
comparison tests/test-profile.t @ 40200:9cc411952ab9
py3: flush stdout
This avoids buffering due to mixed print() and sys.stdout.write() by
profiling code.
And with this, test-profile.t passes on Python 3 \o/.
Honestly, I'd be shocked if there weren't more Python 3 encoding issues lingering
in the profiling code. That code isn't super high quality and doesn't seem to have
thorough test coverage.
Differential Revision: https://phab.mercurial-scm.org/D5018
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Fri, 12 Oct 2018 19:17:22 +0200 |
parents | 5abc47d4ca6b |
children | ef6cab7930b3 |
comparison
equal
deleted
inserted
replaced
40199:b594db74dc13 | 40200:9cc411952ab9 |
---|---|
115 profiler extension could be loaded before other extensions | 115 profiler extension could be loaded before other extensions |
116 | 116 |
117 $ cat > fooprof.py <<EOF | 117 $ cat > fooprof.py <<EOF |
118 > from __future__ import absolute_import | 118 > from __future__ import absolute_import |
119 > import contextlib | 119 > import contextlib |
120 > import sys | |
120 > @contextlib.contextmanager | 121 > @contextlib.contextmanager |
121 > def profile(ui, fp): | 122 > def profile(ui, fp): |
122 > print('fooprof: start profile') | 123 > print('fooprof: start profile') |
124 > sys.stdout.flush() | |
123 > yield | 125 > yield |
124 > print('fooprof: end profile') | 126 > print('fooprof: end profile') |
127 > sys.stdout.flush() | |
125 > def extsetup(ui): | 128 > def extsetup(ui): |
126 > ui.write(b'fooprof: loaded\n') | 129 > ui.write(b'fooprof: loaded\n') |
127 > EOF | 130 > EOF |
128 | 131 |
129 $ cat > otherextension.py <<EOF | 132 $ cat > otherextension.py <<EOF |