11import unittest
2- from _apple_support import SystemLog
2+ from _apple_support import LogStream , SystemLog
33from test .support import is_apple
44from unittest .mock import Mock , call
55
66if not is_apple :
77 raise unittest .SkipTest ("Apple-specific" )
88
9+ MARKER = LogStream .PARTIAL_LINE_MARKER
910
1011# Test redirection of stdout and stderr to the Apple system log.
1112class TestAppleSystemLogOutput (unittest .TestCase ):
@@ -52,6 +53,21 @@ def test_simple_str(self):
5253
5354 self .assert_writes ([b"hello world\n " ])
5455
56+ def test_partial_line_marker (self ):
57+ self .log .write ("complete\n " )
58+ self .assert_writes ([b"complete\n " ])
59+
60+ self .log .write ("partial" )
61+ self .log .flush ()
62+ self .assert_writes ([b"partial" + MARKER ])
63+
64+ self .log .write ("trailing whitespace " )
65+ self .log .flush ()
66+ self .assert_writes ([b"trailing whitespace " + MARKER ])
67+
68+ self .log .write ("done\n " )
69+ self .assert_writes ([b"done\n " ])
70+
5571 def test_buffered_str (self ):
5672 self .log .write ("h" )
5773 self .log .write ("ello" )
@@ -60,7 +76,7 @@ def test_buffered_str(self):
6076 self .log .write ("goodbye." )
6177 self .log .flush ()
6278
63- self .assert_writes ([b"hello world\n " , b"goodbye." ])
79+ self .assert_writes ([b"hello world\n " , b"goodbye." + MARKER ])
6480
6581 def test_manual_flush (self ):
6682 self .log .write ("Hello" )
@@ -74,7 +90,7 @@ def test_manual_flush(self):
7490 self .assert_writes ([b"Goodbye world\n " ])
7591
7692 self .log .flush ()
77- self .assert_writes ([b"Hello again" ])
93+ self .assert_writes ([b"Hello again" + MARKER ])
7894
7995 def test_non_ascii (self ):
8096 # Spanish
@@ -142,7 +158,7 @@ def test_byteslike_in_buffer(self):
142158 self .log .buffer .write (b"goodbye" )
143159 self .log .flush ()
144160
145- self .assert_writes ([b"hello" , b"goodbye" ])
161+ self .assert_writes ([b"hello" + MARKER , b"goodbye" + MARKER ])
146162
147163 def test_non_byteslike_in_buffer (self ):
148164 for obj in ["hello" , None , 42 ]:
0 commit comments