From 6856b04629a18e9147ee6838f630b0367c56e8d8 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Fri, 22 Jun 2018 17:25:38 -0400 Subject: Add test for py2 to_Bytes properly handling unicode string and converting it to a bytearray utf-8 encoded. This was breaking python action functions with unicode constant strings --- src/engine/SCons/UtilTests.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/engine/SCons/UtilTests.py b/src/engine/SCons/UtilTests.py index 6b12f8a..38b4da9 100644 --- a/src/engine/SCons/UtilTests.py +++ b/src/engine/SCons/UtilTests.py @@ -307,6 +307,14 @@ class UtilTestCase(unittest.TestCase): if HasUnicode: exec("assert not is_Tuple(u'')") + def test_to_Bytes(self): + """ Test the to_Bytes method""" + if not PY3: + self.assertEqual(to_bytes(UnicodeType('Hello')), + bytearray(u'Hello', 'utf-8'), + "Check that to_bytes creates byte array when presented with unicode string. PY2 only") + + def test_to_String(self): """Test the to_String() method.""" assert to_String(1) == "1", to_String(1) @@ -843,17 +851,8 @@ class flattenTestCase(unittest.TestCase): if __name__ == "__main__": - suite = unittest.TestSuite() - tclasses = [ dictifyTestCase, - flattenTestCase, - MD5TestCase, - NodeListTestCase, - UtilTestCase, - ] - for tclass in tclasses: - names = unittest.getTestCaseNames(tclass, 'test_') - suite.addTests(list(map(tclass, names))) - TestUnit.run(suite) + unittest.main() + # Local Variables: # tab-width:4 -- cgit v0.12