tests: force `dummysmtpd.py` to write its log file with '\n' on Windows
authorMatt Harbison <matt_harbison@yahoo.com>
Tue, 15 Oct 2024 18:35:45 -0400
changeset 52093 dbd2d56224d1
parent 52092 e2311951b63a
child 52094 87faafd6ea83
tests: force `dummysmtpd.py` to write its log file with '\n' on Windows The log files were being `cat'd` in `test-patchbomb-tls.t`, and causing gratuitous failures. Since `sys.stdout` is being written to with `str` instead of `bytes`, use a `io.TextIOWrapper` to change the EOL, like 2924676d4728.
tests/dummysmtpd.py
--- a/tests/dummysmtpd.py	Mon Oct 14 20:11:27 2024 -0400
+++ b/tests/dummysmtpd.py	Tue Oct 15 18:35:45 2024 -0400
@@ -3,6 +3,7 @@
 """dummy SMTP server for use in tests"""
 
 
+import io
 import optparse
 import os
 import socket
@@ -16,6 +17,13 @@
     ui as uimod,
 )
 
+if pycompat.iswindows:
+    sys.stdout = io.TextIOWrapper(
+        sys.stdout.buffer,
+        sys.stdout.encoding,
+        sys.stdout.errors,
+        newline="\n",
+    )
 
 if os.environ.get('HGIPV6', '0') == '1':
     family = socket.AF_INET6