mirror of
				https://github.com/buildbot/buildbot.git
				synced 2021-05-20 10:47:20 +03:00 
			
		
		
		
	worker: add test for invalid utf-8 output
This commit is contained in:
		@@ -177,6 +177,23 @@ class TestRunProcess(BasedirMixin, unittest.TestCase):
 | 
			
		||||
        self.assertTrue({'stdout': u"\N{SNOWMAN}"} in b.updates)
 | 
			
		||||
        self.assertTrue({'rc': 0} in b.updates, b.show())
 | 
			
		||||
 | 
			
		||||
    @defer.inlineCallbacks
 | 
			
		||||
    def testInvalidUTF8(self):
 | 
			
		||||
        b = FakeWorkerForBuilder(self.basedir)
 | 
			
		||||
        b.unicode_encoding = "utf-8"
 | 
			
		||||
        s = runprocess.RunProcess(
 | 
			
		||||
            b, stderrCommand("hello"), self.basedir, sendStderr=True)
 | 
			
		||||
        pp = runprocess.RunProcessPP(s)
 | 
			
		||||
        INVALID_UTF8 = b"\xff"
 | 
			
		||||
        with self.assertRaises(UnicodeDecodeError):
 | 
			
		||||
            INVALID_UTF8.decode('utf-8')
 | 
			
		||||
        pp.outReceived(INVALID_UTF8)
 | 
			
		||||
        yield s.start()
 | 
			
		||||
        stdout = [up['stdout'] for up in b.updates if 'stdout' in up][0]
 | 
			
		||||
        # On Python < 2.7 bytes is used, on Python >= 2.7 unicode
 | 
			
		||||
        self.assertIn(stdout, (b'\xef\xbf\xbd', u'\ufffd'))
 | 
			
		||||
        self.assertTrue({'rc': 0} in b.updates, b.show())
 | 
			
		||||
 | 
			
		||||
    @defer.inlineCallbacks
 | 
			
		||||
    def testKeepStderr(self):
 | 
			
		||||
        b = FakeWorkerForBuilder(self.basedir)
 | 
			
		||||
 
 | 
			
		||||
@@ -4,7 +4,8 @@
 | 
			
		||||
# and then run "tox" from this directory.
 | 
			
		||||
 | 
			
		||||
[tox]
 | 
			
		||||
envlist = py24, py25, py26, py27
 | 
			
		||||
envlist = py24, py25, py26, py27, py35, py36, py37
 | 
			
		||||
 | 
			
		||||
[testenv]
 | 
			
		||||
deps = setuptools_trial
 | 
			
		||||
commands = python setup.py test
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user