diff --git a/tests/test-ssh-proto-unbundle.t b/tests/test-ssh-proto-unbundle.t
index 32bc3815efae1ab28c2b4d0ae3c26a91527fc5a4_dGVzdHMvdGVzdC1zc2gtcHJvdG8tdW5idW5kbGUudA==..45a669bad4212a7cdf0e1747784aede74590ac52_dGVzdHMvdGVzdC1zc2gtcHJvdG8tdW5idW5kbGUudA== 100644
--- a/tests/test-ssh-proto-unbundle.t
+++ b/tests/test-ssh-proto-unbundle.t
@@ -161,7 +161,8 @@
   > import sys
   > def hook1line(ui, repo, **kwargs):
   >     ui.write(b'ui.write 1 line\n')
+  >     ui.flush()
   >     return 1
   > def hook2lines(ui, repo, **kwargs):
   >     ui.write(b'ui.write 2 lines 1\n')
   >     ui.write(b'ui.write 2 lines 2\n')
@@ -164,7 +165,8 @@
   >     return 1
   > def hook2lines(ui, repo, **kwargs):
   >     ui.write(b'ui.write 2 lines 1\n')
   >     ui.write(b'ui.write 2 lines 2\n')
+  >     ui.flush()
   >     return 1
   > def hook1lineflush(ui, repo, **kwargs):
   >     ui.write(b'ui.write 1 line flush\n')
@@ -181,6 +183,7 @@
   >     ui.write_err(b'ui.write_err 1\n')
   >     ui.write(b'ui.write 2\n')
   >     ui.write_err(b'ui.write_err 2\n')
+  >     ui.flush()
   >     return 1
   > def hookprintstdout(ui, repo, **kwargs):
   >     print('printed line')
@@ -184,6 +187,7 @@
   >     return 1
   > def hookprintstdout(ui, repo, **kwargs):
   >     print('printed line')
+  >     sys.stdout.flush()
   >     return 1
   > def hookprintandwrite(ui, repo, **kwargs):
   >     print('print 1')
@@ -187,4 +191,5 @@
   >     return 1
   > def hookprintandwrite(ui, repo, **kwargs):
   >     print('print 1')
+  >     sys.stdout.flush()
   >     ui.write(b'ui.write 1\n')
@@ -190,2 +195,3 @@
   >     ui.write(b'ui.write 1\n')
+  >     ui.flush()
   >     print('print 2')
@@ -191,2 +197,3 @@
   >     print('print 2')
+  >     sys.stdout.flush()
   >     ui.write(b'ui.write 2\n')
@@ -192,4 +199,5 @@
   >     ui.write(b'ui.write 2\n')
+  >     ui.flush()
   >     return 1
   > def hookprintstderrandstdout(ui, repo, **kwargs):
   >     print('stdout 1')
@@ -193,4 +201,5 @@
   >     return 1
   > def hookprintstderrandstdout(ui, repo, **kwargs):
   >     print('stdout 1')
+  >     sys.stdout.flush()
   >     print('stderr 1', file=sys.stderr)
@@ -196,2 +205,3 @@
   >     print('stderr 1', file=sys.stderr)
+  >     sys.stderr.flush()
   >     print('stdout 2')
@@ -197,2 +207,3 @@
   >     print('stdout 2')
+  >     sys.stdout.flush()
   >     print('stderr 2', file=sys.stderr)
@@ -198,4 +209,5 @@
   >     print('stderr 2', file=sys.stderr)
+  >     sys.stderr.flush()
   >     return 1
   > EOF
 
@@ -1046,4 +1058,5 @@
   e>     adding manifests\n
   e>     adding file changes\n
   e>     added 1 changesets with 1 changes to 1 files\n
+  e>     print 1\n
   e>     ui.write 1\n
@@ -1049,2 +1062,3 @@
   e>     ui.write 1\n
+  e>     print 2\n
   e>     ui.write 2\n
@@ -1050,6 +1064,4 @@
   e>     ui.write 2\n
-  e>     print 1\n
-  e>     print 2\n
   e>     transaction abort!\n
   e>     rollback completed\n
   e>     abort: pretxnchangegroup.fail hook failed\n
@@ -1106,4 +1118,5 @@
   e>     adding manifests\n
   e>     adding file changes\n
   e>     added 1 changesets with 1 changes to 1 files\n
+  e>     print 1\n
   e>     ui.write 1\n
@@ -1109,2 +1122,3 @@
   e>     ui.write 1\n
+  e>     print 2\n
   e>     ui.write 2\n
@@ -1110,6 +1124,4 @@
   e>     ui.write 2\n
-  e>     print 1\n
-  e>     print 2\n
   e>     transaction abort!\n
   e>     rollback completed\n
   e>     abort: pretxnchangegroup.fail hook failed\n
@@ -1180,4 +1192,5 @@
   e>     adding manifests\n
   e>     adding file changes\n
   e>     added 1 changesets with 1 changes to 1 files\n
+  e>     stdout 1\n
   e>     stderr 1\n
@@ -1183,2 +1196,3 @@
   e>     stderr 1\n
+  e>     stdout 2\n
   e>     stderr 2\n
@@ -1184,6 +1198,4 @@
   e>     stderr 2\n
-  e>     stdout 1\n
-  e>     stdout 2\n
   e>     transaction abort!\n
   e>     rollback completed\n
   e>     abort: pretxnchangegroup.fail hook failed\n
@@ -1240,4 +1252,5 @@
   e>     adding manifests\n
   e>     adding file changes\n
   e>     added 1 changesets with 1 changes to 1 files\n
+  e>     stdout 1\n
   e>     stderr 1\n
@@ -1243,2 +1256,3 @@
   e>     stderr 1\n
+  e>     stdout 2\n
   e>     stderr 2\n
@@ -1244,6 +1258,4 @@
   e>     stderr 2\n
-  e>     stdout 1\n
-  e>     stdout 2\n
   e>     transaction abort!\n
   e>     rollback completed\n
   e>     abort: pretxnchangegroup.fail hook failed\n
@@ -1731,4 +1743,5 @@
   e>     shell stderr 1\n
   e>     shell stdout 2\n
   e>     shell stderr 2\n
+  e>     stdout 1\n
   e>     stderr 1\n
@@ -1734,2 +1747,3 @@
   e>     stderr 1\n
+  e>     stdout 2\n
   e>     stderr 2\n
@@ -1735,6 +1749,4 @@
   e>     stderr 2\n
-  e>     stdout 1\n
-  e>     stdout 2\n
   e>     transaction abort!\n
   e>     rollback completed\n
   e>     abort: pretxnchangegroup.b hook failed\n
@@ -1795,4 +1807,5 @@
   e>     shell stderr 1\n
   e>     shell stdout 2\n
   e>     shell stderr 2\n
+  e>     stdout 1\n
   e>     stderr 1\n
@@ -1798,2 +1811,3 @@
   e>     stderr 1\n
+  e>     stdout 2\n
   e>     stderr 2\n
@@ -1799,6 +1813,4 @@
   e>     stderr 2\n
-  e>     stdout 1\n
-  e>     stdout 2\n
   e>     transaction abort!\n
   e>     rollback completed\n
   e>     abort: pretxnchangegroup.b hook failed\n
diff --git a/tests/test-ssh.t b/tests/test-ssh.t
index 32bc3815efae1ab28c2b4d0ae3c26a91527fc5a4_dGVzdHMvdGVzdC1zc2gudA==..45a669bad4212a7cdf0e1747784aede74590ac52_dGVzdHMvdGVzdC1zc2gudA== 100644
--- a/tests/test-ssh.t
+++ b/tests/test-ssh.t
@@ -272,9 +272,10 @@
   $ cat <<EOF > $TESTTMP/badhook
   > import sys
   > sys.stdout.write("KABOOM\n")
+  > sys.stdout.flush()
   > EOF
 
   $ cat <<EOF > $TESTTMP/badpyhook.py
   > import sys
   > def hook(ui, repo, hooktype, **kwargs):
   >     sys.stdout.write("KABOOM IN PROCESS\n")
@@ -275,9 +276,10 @@
   > EOF
 
   $ cat <<EOF > $TESTTMP/badpyhook.py
   > import sys
   > def hook(ui, repo, hooktype, **kwargs):
   >     sys.stdout.write("KABOOM IN PROCESS\n")
+  >     sys.stdout.flush()
   > EOF
 
   $ cat <<EOF >> ../remote/.hg/hgrc
@@ -456,6 +458,7 @@
   > def wrappedpush(orig, repo, *args, **kwargs):
   >     res = orig(repo, *args, **kwargs)
   >     repo.ui.write('local stdout\n')
+  >     repo.ui.flush()
   >     return res
   > 
   > def extsetup(ui):