From ea5dd4f257f45b41984dd83640c6b7abf57a663d Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Thu, 14 Apr 2011 19:56:12 -0300 Subject: Fix bug 717 - "QByteArray doesn't honor \0 inside strings." MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewer: Renato Araújo Marcelo Lira --- tests/QtCore/qbytearray_concatenation_operator_test.py | 15 ++++++--------- tests/QtCore/qbytearray_test.py | 2 +- 2 files changed, 7 insertions(+), 10 deletions(-) (limited to 'tests/QtCore') diff --git a/tests/QtCore/qbytearray_concatenation_operator_test.py b/tests/QtCore/qbytearray_concatenation_operator_test.py index b9a01ff63..13fd231f7 100644 --- a/tests/QtCore/qbytearray_concatenation_operator_test.py +++ b/tests/QtCore/qbytearray_concatenation_operator_test.py @@ -12,20 +12,17 @@ class QByteArrayConcatenationOperatorTest(unittest.TestCase): def testConcatQByteArrayAndPythonString(self): #Test concatenation of a QByteArray with a Python string, in this order qba = QByteArray('foo') - result = qba + 'bar' - self.assert_(isinstance(result, QByteArray)) - self.assertEqual(result, 'foobar') - # NOTICE: the standard behavior of PyQt is to return a QString object - # for this case. As this is a minor issue the assertion will be left commented. - #self.assertEqual(result.__class__.__name__, 'QString') + result = qba + '\x00bar' + self.assertEqual(type(result), QByteArray) + self.assertEqual(result, 'foo\x00bar') def testConcatPythonStringAndQByteArray(self): #Test concatenation of a Python string with a QByteArray, in this order concat_python_string_add_qbytearray_worked = True qba = QByteArray('foo') - result = 'bar' + qba - self.assert_(isinstance(result, QByteArray)) - self.assertEqual(result, 'barfoo') + result = 'bar\x00' + qba + self.assertEqual(type(result), QByteArray) + self.assertEqual(result, 'bar\x00foo') # NOTICE: Does not makes sense concat a unicode string with a QByteArray, because the # user does not know nothing about the internal representation of the unicode string. diff --git a/tests/QtCore/qbytearray_test.py b/tests/QtCore/qbytearray_test.py index 330a7d09f..38ed2ab1c 100644 --- a/tests/QtCore/qbytearray_test.py +++ b/tests/QtCore/qbytearray_test.py @@ -152,7 +152,7 @@ class QByteArrayBug720(unittest.TestCase): def testIt(self): ba = QByteArray("32\"1\x00123") self.assertEqual(str(ba), "32\"1\x00123") - self.assertEqual(repr(ba), "PySide.QtCore.QByteArray(\"32\\\"1\x00123\")") + self.assertEqual(repr(ba), "PySide.QtCore.QByteArray('32\"1\\x00123')") if __name__ == '__main__': -- cgit v1.2.3