@@ -136,6 +136,54 @@ def test_issue_1224(self):
136136 self .addCleanup (supervisord .kill , signal .SIGINT )
137137 supervisord .expect_exact ('cat entered RUNNING state' , timeout = 60 )
138138
139+ def test_issue_1231a (self ):
140+ filename = pkg_resources .resource_filename (__name__ , 'fixtures/issue-1231.conf' )
141+ args = ['-m' , 'supervisor.supervisord' , '-c' , filename ]
142+ supervisord = pexpect .spawn (sys .executable , args , encoding = 'utf-8' )
143+ self .addCleanup (supervisord .kill , signal .SIGINT )
144+ supervisord .expect_exact ('success: hello entered RUNNING state' )
145+
146+ args = ['-m' , 'supervisor.supervisorctl' , '-c' , filename , 'tail' , '-f' , 'hello' ]
147+ supervisorctl = pexpect .spawn (sys .executable , args , encoding = 'utf-8' )
148+ self .addCleanup (supervisorctl .kill , signal .SIGINT )
149+
150+ for i in range (1 , 4 ):
151+ line = '%d - hash=57d94b…381088' % i
152+ supervisorctl .expect_exact (line , timeout = 30 )
153+
154+
155+ def test_issue_1231b (self ):
156+ filename = pkg_resources .resource_filename (__name__ , 'fixtures/issue-1231.conf' )
157+ args = ['-m' , 'supervisor.supervisord' , '-c' , filename ]
158+ supervisord = pexpect .spawn (sys .executable , args , encoding = 'utf-8' )
159+ self .addCleanup (supervisord .kill , signal .SIGINT )
160+ supervisord .expect_exact ('success: hello entered RUNNING state' )
161+
162+ args = ['-m' , 'supervisor.supervisorctl' , '-c' , filename , 'tail' , '-f' , 'hello' ]
163+ env = os .environ .copy ()
164+ env ['LANG' ] = 'oops'
165+ supervisorctl = pexpect .spawn (sys .executable , args , encoding = 'utf-8' ,
166+ env = env )
167+ self .addCleanup (supervisorctl .kill , signal .SIGINT )
168+
169+ # For Python 3 < 3.7, LANG=oops leads to warnings because of the
170+ # stdout encoding. For 3.7 (and presumably later), the encoding is
171+ # utf-8 when LANG=oops.
172+ if sys .version_info [:2 ] < (3 , 7 ):
173+ supervisorctl .expect ('Warning: sys.stdout.encoding is set to ' ,
174+ timeout = 30 )
175+ supervisorctl .expect ('Unicode output may fail.' , timeout = 30 )
176+
177+ for i in range (1 , 4 ):
178+ line = '%d - hash=57d94b…381088' % i
179+ try :
180+ supervisorctl .expect_exact (line , timeout = 30 )
181+ except pexpect .exceptions .EOF :
182+ self .assertIn ('Unable to write Unicode to stdout because it '
183+ 'has encoding ' ,
184+ supervisorctl .before )
185+ break
186+
139187
140188def test_suite ():
141189 return unittest .findTestCases (sys .modules [__name__ ])
0 commit comments