Fixing several tests
Using isinstance instead of comparing classes names Removing unnecessary tuple check, treated by the return value unpacking Adding missing inject code tests Adding qfile.getchar test Fixing QLocale.to* methods fixing __setitem__ in qbytearray
This commit is contained in:
parent
76529055ff
commit
74351882b5
13 changed files with 291 additions and 45 deletions
|
|
@ -1210,11 +1210,27 @@
|
||||||
<modify-function signature="toString(qulonglong) const" remove="all"/>
|
<modify-function signature="toString(qulonglong) const" remove="all"/>
|
||||||
<modify-function signature="toString(ushort) const" remove="all"/>
|
<modify-function signature="toString(ushort) const" remove="all"/>
|
||||||
<modify-function signature="toString(unsigned int) const" remove="all"/>
|
<modify-function signature="toString(unsigned int) const" remove="all"/>
|
||||||
<modify-function signature="toUInt(QString,bool*,int)const" remove="all"/>
|
|
||||||
<modify-function signature="toULongLong(QString,bool*,int)const" remove="all"/>
|
|
||||||
<extra-includes>
|
<extra-includes>
|
||||||
<include file-name="QDate" location="global"/>
|
<include file-name="QDate" location="global"/>
|
||||||
</extra-includes>
|
</extra-includes>
|
||||||
|
<modify-function signature="toUInt(QString,bool*,int)const">
|
||||||
|
<modify-argument index="2">
|
||||||
|
<remove-argument />
|
||||||
|
<remove-default-expression />
|
||||||
|
</modify-argument>
|
||||||
|
<inject-code class="target" position="beginning">
|
||||||
|
<insert-template name="fix_arg,bool*,arg" />
|
||||||
|
</inject-code>
|
||||||
|
</modify-function>
|
||||||
|
<modify-function signature="toULongLong(QString,bool*,int)const">
|
||||||
|
<modify-argument index="2">
|
||||||
|
<remove-argument />
|
||||||
|
<remove-default-expression />
|
||||||
|
</modify-argument>
|
||||||
|
<inject-code class="target" position="beginning">
|
||||||
|
<insert-template name="fix_arg,bool*,arg" />
|
||||||
|
</inject-code>
|
||||||
|
</modify-function>
|
||||||
<modify-function signature="toDouble(QString,bool*)const">
|
<modify-function signature="toDouble(QString,bool*)const">
|
||||||
<modify-argument index="2">
|
<modify-argument index="2">
|
||||||
<remove-argument />
|
<remove-argument />
|
||||||
|
|
@ -1241,10 +1257,30 @@
|
||||||
<insert-template name="fix_arg,bool*,arg" />
|
<insert-template name="fix_arg,bool*,arg" />
|
||||||
</inject-code>
|
</inject-code>
|
||||||
</modify-function>
|
</modify-function>
|
||||||
|
<modify-function signature="toLongLong(QString,bool*,int)const">
|
||||||
<modify-function signature="toLongLong(QString,bool*,int)const" remove="all" />
|
<modify-argument index="2">
|
||||||
<modify-function signature="toShort(QString,bool*,int)const" remove="all" />
|
<remove-argument />
|
||||||
<modify-function signature="toUShort(QString,bool*,int)const" remove="all" />
|
</modify-argument>
|
||||||
|
<inject-code class="target" position="beginning">
|
||||||
|
<insert-template name="fix_arg,bool*,arg" />
|
||||||
|
</inject-code>
|
||||||
|
</modify-function>
|
||||||
|
<modify-function signature="toShort(QString,bool*,int)const">
|
||||||
|
<modify-argument index="2">
|
||||||
|
<remove-argument />
|
||||||
|
</modify-argument>
|
||||||
|
<inject-code class="target" position="beginning">
|
||||||
|
<insert-template name="fix_arg,bool*,arg" />
|
||||||
|
</inject-code>
|
||||||
|
</modify-function>
|
||||||
|
<modify-function signature="toUShort(QString,bool*,int)const">
|
||||||
|
<modify-argument index="2">
|
||||||
|
<remove-argument />
|
||||||
|
</modify-argument>
|
||||||
|
<inject-code class="target" position="beginning">
|
||||||
|
<insert-template name="fix_arg,bool*,arg" />
|
||||||
|
</inject-code>
|
||||||
|
</modify-function>
|
||||||
</value-type>
|
</value-type>
|
||||||
<value-type name="QBitArray" hash-function="qHash" >
|
<value-type name="QBitArray" hash-function="qHash" >
|
||||||
<modify-function signature="fill(bool,int)" remove="all"/> <!-- FIXME Removed due to a shiboken bug-->
|
<modify-function signature="fill(bool,int)" remove="all"/> <!-- FIXME Removed due to a shiboken bug-->
|
||||||
|
|
@ -2015,8 +2051,9 @@
|
||||||
</add-function>
|
</add-function>
|
||||||
<add-function signature="__setitem__">
|
<add-function signature="__setitem__">
|
||||||
<inject-code class="target" position="beginning">
|
<inject-code class="target" position="beginning">
|
||||||
PyObject* args = Py_BuildValue("(iiO)", _i, 1, _value);
|
%CPPSELF.remove(_i, 1);
|
||||||
PyObject* result = SbkQByteArrayFunc_replace(self, args);
|
PyObject* args = Py_BuildValue("(nO)", _i, _value);
|
||||||
|
PyObject* result = SbkQByteArrayFunc_insert(self, args);
|
||||||
Py_DECREF(args);
|
Py_DECREF(args);
|
||||||
Py_XDECREF(result);
|
Py_XDECREF(result);
|
||||||
return !result ? -1 : 0;
|
return !result ? -1 : 0;
|
||||||
|
|
|
||||||
|
|
@ -95,6 +95,25 @@ class QBitArrayIsIterableTest(unittest.TestCase):
|
||||||
self.assertTrue(has_xor_bitwise_operator)
|
self.assertTrue(has_xor_bitwise_operator)
|
||||||
self.assertEqual(bool_list_from_qbitarray(xored_qbitarray), xored_bool_list)
|
self.assertEqual(bool_list_from_qbitarray(xored_qbitarray), xored_bool_list)
|
||||||
|
|
||||||
|
|
||||||
|
class QBitArrayGetItemTest(unittest.TestCase):
|
||||||
|
'''Test case for []/__getitem__ operator'''
|
||||||
|
|
||||||
|
def create_bitarray(self, values):
|
||||||
|
'''helper function to create a bit array'''
|
||||||
|
obj = QBitArray(len(values))
|
||||||
|
for i, value in enumerate(values):
|
||||||
|
obj.setBit(i, value)
|
||||||
|
return obj
|
||||||
|
|
||||||
|
def testSequenceProtocol(self):
|
||||||
|
'''QBitArray sequence protocol'''
|
||||||
|
data = [True, False, True]
|
||||||
|
obj = self.create_bitarray(data)
|
||||||
|
for reference, value in zip(data, obj):
|
||||||
|
self.assertEqual(reference, value)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,12 +13,7 @@ class QByteArrayBufferProtocolTest(unittest.TestCase):
|
||||||
def testQByteArrayBufferProtocol(self):
|
def testQByteArrayBufferProtocol(self):
|
||||||
#Tests QByteArray implementation of Python buffer protocol using the os.path.isdir
|
#Tests QByteArray implementation of Python buffer protocol using the os.path.isdir
|
||||||
#function which an unicode object or other object implementing the Python buffer protocol
|
#function which an unicode object or other object implementing the Python buffer protocol
|
||||||
os_path_isdir_function_correctly_called_with_a_qbytearray = True
|
|
||||||
try:
|
|
||||||
isdir(QByteArray('/tmp'))
|
isdir(QByteArray('/tmp'))
|
||||||
except:
|
|
||||||
os_path_isdir_function_correctly_called_with_a_qbytearray = False
|
|
||||||
self.assertTrue(os_path_isdir_function_correctly_called_with_a_qbytearray)
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
|
||||||
|
|
@ -11,14 +11,10 @@ class QByteArrayConcatenationOperatorTest(unittest.TestCase):
|
||||||
|
|
||||||
def testConcatQByteArrayAndPythonString(self):
|
def testConcatQByteArrayAndPythonString(self):
|
||||||
#Test concatenation of a QByteArray with a Python string, in this order
|
#Test concatenation of a QByteArray with a Python string, in this order
|
||||||
concat_qbytearray_add_python_string_worked = True
|
|
||||||
qba = QByteArray('foo')
|
qba = QByteArray('foo')
|
||||||
result = None
|
|
||||||
try:
|
|
||||||
result = qba + 'bar'
|
result = qba + 'bar'
|
||||||
except:
|
self.assert_(isinstance(result, QByteArray))
|
||||||
concat_qbytearray_add_python_string_worked = False
|
self.assertEqual(result, 'foobar')
|
||||||
self.assertTrue(concat_qbytearray_add_python_string_worked)
|
|
||||||
# NOTICE: the standard behavior of PyQt is to return a QString object
|
# 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.
|
# for this case. As this is a minor issue the assertion will be left commented.
|
||||||
#self.assertEqual(result.__class__.__name__, 'QString')
|
#self.assertEqual(result.__class__.__name__, 'QString')
|
||||||
|
|
@ -27,13 +23,9 @@ class QByteArrayConcatenationOperatorTest(unittest.TestCase):
|
||||||
#Test concatenation of a Python string with a QByteArray, in this order
|
#Test concatenation of a Python string with a QByteArray, in this order
|
||||||
concat_python_string_add_qbytearray_worked = True
|
concat_python_string_add_qbytearray_worked = True
|
||||||
qba = QByteArray('foo')
|
qba = QByteArray('foo')
|
||||||
result = None
|
|
||||||
try:
|
|
||||||
result = 'bar' + qba
|
result = 'bar' + qba
|
||||||
except:
|
self.assert_(isinstance(result, QByteArray))
|
||||||
concat_python_string_add_qbytearray_worked = False
|
self.assertEqual(result, 'barfoo')
|
||||||
self.assertTrue(concat_python_string_add_qbytearray_worked)
|
|
||||||
self.assertEqual(result.__class__.__name__, 'QByteArray')
|
|
||||||
|
|
||||||
# NOTICE: Does not makes sense concat a unicode string with a QByteArray, because the
|
# 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.
|
# user does not know nothing about the internal representation of the unicode string.
|
||||||
|
|
|
||||||
|
|
@ -57,5 +57,26 @@ class QByteArrayOperatorAt(unittest.TestCase):
|
||||||
self.assertRaises(IndexError, lambda :obj[len(string)])
|
self.assertRaises(IndexError, lambda :obj[len(string)])
|
||||||
|
|
||||||
|
|
||||||
|
class QByteArrayOperatorLen(unittest.TestCase):
|
||||||
|
'''Test case for __len__ operator of QByteArray'''
|
||||||
|
|
||||||
|
def testBasic(self):
|
||||||
|
'''QByteArray __len__'''
|
||||||
|
self.assertEqual(len(QByteArray()), 0)
|
||||||
|
self.assertEqual(len(QByteArray('')), 0)
|
||||||
|
self.assertEqual(len(QByteArray(' ')), 1)
|
||||||
|
self.assertEqual(len(QByteArray('yabadaba')), 8)
|
||||||
|
|
||||||
|
|
||||||
|
class QByteArrayOperatorStr(unittest.TestCase):
|
||||||
|
'''Test case for __str__ operator of QByteArray'''
|
||||||
|
|
||||||
|
def testBasic(self):
|
||||||
|
'''QByteArray __str__'''
|
||||||
|
self.assertEqual(QByteArray().__str__(), '')
|
||||||
|
self.assertEqual(QByteArray('').__str__(), '')
|
||||||
|
self.assertEqual(QByteArray('aaa').__str__(), 'aaa')
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
|
||||||
|
|
@ -10,17 +10,21 @@ from PySide.QtCore import QByteArray
|
||||||
class QByteArrayTestToNumber(unittest.TestCase):
|
class QByteArrayTestToNumber(unittest.TestCase):
|
||||||
def testToNumberInt(self):
|
def testToNumberInt(self):
|
||||||
obj = QByteArray('37')
|
obj = QByteArray('37')
|
||||||
self.assertEqual(37, obj.toInt()[0])
|
self.assertEqual((37, True), obj.toInt())
|
||||||
|
|
||||||
|
def testToNumberUShort(self):
|
||||||
|
obj = QByteArray('37')
|
||||||
|
self.assertEqual((37, True), obj.toUShort())
|
||||||
|
|
||||||
def testToNumberFloat(self):
|
def testToNumberFloat(self):
|
||||||
obj = QByteArray('37.109')
|
obj = QByteArray('37.109')
|
||||||
self.assertEqual(ctypes.c_float(37.109).value,
|
self.assertEqual((ctypes.c_float(37.109).value, True),
|
||||||
obj.toFloat()[0])
|
obj.toFloat())
|
||||||
|
|
||||||
def testToNumberDouble(self):
|
def testToNumberDouble(self):
|
||||||
obj = QByteArray('37.109')
|
obj = QByteArray('37.109')
|
||||||
self.assertEqual(ctypes.c_double(37.109).value,
|
self.assertEqual((ctypes.c_double(37.109).value, True),
|
||||||
obj.toDouble()[0])
|
obj.toDouble())
|
||||||
|
|
||||||
class QByteArraySplit(unittest.TestCase):
|
class QByteArraySplit(unittest.TestCase):
|
||||||
'''Test case for QByteArray.split'''
|
'''Test case for QByteArray.split'''
|
||||||
|
|
@ -38,6 +42,57 @@ class QByteArrayData(unittest.TestCase):
|
||||||
url = QByteArray("http://web.openbossa.org/")
|
url = QByteArray("http://web.openbossa.org/")
|
||||||
self.assertEqual(url.data(), "http://web.openbossa.org/")
|
self.assertEqual(url.data(), "http://web.openbossa.org/")
|
||||||
|
|
||||||
|
class QByteArrayOperatorAtSetter(unittest.TestCase):
|
||||||
|
'''Test case for operator QByteArray[] - __setitem__'''
|
||||||
|
|
||||||
|
def testSetterString(self):
|
||||||
|
'''QByteArray[x] = pythonstring'''
|
||||||
|
obj = QByteArray('123456')
|
||||||
|
obj[1] = '0'
|
||||||
|
self.assertEqual(obj, QByteArray('103456'))
|
||||||
|
|
||||||
|
def testSetterStringLarge(self):
|
||||||
|
'''QByteArray[x] = pythonstring (larget than 1 char)'''
|
||||||
|
obj = QByteArray('123456')
|
||||||
|
obj[3] = 'abba'
|
||||||
|
self.assertEqual(obj, QByteArray('123abba56'))
|
||||||
|
|
||||||
|
def testSetterQByteArray(self):
|
||||||
|
'''QByteArray[x] = qbytearray'''
|
||||||
|
obj = QByteArray('123456')
|
||||||
|
obj[3] = QByteArray('array')
|
||||||
|
self.assertEqual(obj, QByteArray('123array56'))
|
||||||
|
|
||||||
|
|
||||||
|
class QByteArrayOperatorAtSetterNegativeIndex(unittest.TestCase):
|
||||||
|
'''Test case for QByteArray[] - __setitem__ - for negative index'''
|
||||||
|
|
||||||
|
def testSetterNegativeIndex(self):
|
||||||
|
'''QByteArray[x] = string - negative index'''
|
||||||
|
obj = QByteArray('123456')
|
||||||
|
obj[-3] = 'array'
|
||||||
|
self.assertEqual(obj, QByteArray('123array56'))
|
||||||
|
|
||||||
|
|
||||||
|
class QByteArrayOperatorAtSetterLargeIndex(unittest.TestCase):
|
||||||
|
'''Test case for QByteArray[] - __setitem__ - for 'overflown' index'''
|
||||||
|
|
||||||
|
def testSetterLargeIndexEmpty(self):
|
||||||
|
'''QByteArray[x] = somestring - Overflow index on empty string'''
|
||||||
|
# should pad with spaces if the index is larger
|
||||||
|
obj = QByteArray('')
|
||||||
|
obj[2] = 'a'
|
||||||
|
self.assertEqual(obj, QByteArray(' a'))
|
||||||
|
|
||||||
|
def testSetterLargeIndexNormal(self):
|
||||||
|
'''QByteArray[x] = somestring - Overflow index on normal string'''
|
||||||
|
# should pad with spaces if the index is larger
|
||||||
|
obj = QByteArray('mystring')
|
||||||
|
obj[10] = 'normal'
|
||||||
|
self.assertEqual(obj, QByteArray('mystring normal'))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
|
||||||
33
tests/qtcore/qchar_test.py
Normal file
33
tests/qtcore/qchar_test.py
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
|
||||||
|
'''Test cases for QChar'''
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
from PySide.QtCore import QString, QChar, QTextStream, QLatin1Char
|
||||||
|
|
||||||
|
|
||||||
|
class EqualTest(unittest.TestCase):
|
||||||
|
'''Tests for '__equal__'''
|
||||||
|
|
||||||
|
def testEqualQChar(self):
|
||||||
|
'''QChar == QChar'''
|
||||||
|
self.assertEqual(QChar('a'), QChar('a'))
|
||||||
|
|
||||||
|
def testEqualPyString(self):
|
||||||
|
'''QChar == Python string'''
|
||||||
|
self.assertEqual(QChar('a'), 'a')
|
||||||
|
|
||||||
|
|
||||||
|
class ImplicitConvQLatin1Char(unittest.TestCase):
|
||||||
|
'''Tests for implicit conversion from QLatin1Char to QChar'''
|
||||||
|
|
||||||
|
def testQLatin1CharToChar(self):
|
||||||
|
'''QLatin1Char implicitly convertible to QChar'''
|
||||||
|
stream = QTextStream()
|
||||||
|
stream.setPadChar(QLatin1Char('-'))
|
||||||
|
self.assertEqual(QChar('-'), stream.padChar())
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
||||||
|
|
||||||
31
tests/qtcore/qfile_test.py
Normal file
31
tests/qtcore/qfile_test.py
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
import os
|
||||||
|
import tempfile
|
||||||
|
|
||||||
|
from PySide.QtCore import QFile, QIODevice
|
||||||
|
|
||||||
|
class GetCharTest(unittest.TestCase):
|
||||||
|
'''Test case for QIODevice.getChar in QFile'''
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
'''Acquire resources'''
|
||||||
|
handle, self.filename = tempfile.mkstemp()
|
||||||
|
os.write(handle, 'a')
|
||||||
|
os.close(handle)
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
'''release resources'''
|
||||||
|
os.remove(self.filename)
|
||||||
|
|
||||||
|
def testBasic(self):
|
||||||
|
'''QFile.getChar'''
|
||||||
|
obj = QFile(self.filename)
|
||||||
|
obj.open(QIODevice.ReadOnly)
|
||||||
|
self.assertEqual(obj.getChar(), (True, 'a'))
|
||||||
|
self.assert_(not obj.getChar()[0])
|
||||||
|
obj.close()
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
||||||
21
tests/qtcore/qlatin1string_test.py
Normal file
21
tests/qtcore/qlatin1string_test.py
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
|
||||||
|
'''Test cases for QLatin1String'''
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
from PySide.QtCore import QString, QLatin1String, QObject
|
||||||
|
|
||||||
|
|
||||||
|
class ImplicitConvQLatin1String(unittest.TestCase):
|
||||||
|
'''Tests for implicit conversion from QLatin1String to QString'''
|
||||||
|
|
||||||
|
def testQLatin1String(self):
|
||||||
|
'''QString implicit convertion from QLatin1String'''
|
||||||
|
obj = QObject()
|
||||||
|
obj.setObjectName(QLatin1String('dummy'))
|
||||||
|
|
||||||
|
self.assertEqual(QString('dummy'), obj.objectName())
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
||||||
|
|
||||||
|
|
@ -10,17 +10,31 @@ from PySide.QtCore import QLocale
|
||||||
class QLocaleTestToNumber(unittest.TestCase):
|
class QLocaleTestToNumber(unittest.TestCase):
|
||||||
def testToNumberInt(self):
|
def testToNumberInt(self):
|
||||||
obj = QLocale(QLocale.C)
|
obj = QLocale(QLocale.C)
|
||||||
self.assertEqual(37, obj.toInt('37')[0])
|
self.assertEqual((37, True), obj.toInt('37'))
|
||||||
|
|
||||||
def testToNumberFloat(self):
|
def testToNumberFloat(self):
|
||||||
obj = QLocale(QLocale.C)
|
obj = QLocale(QLocale.C)
|
||||||
self.assertEqual(ctypes.c_float(37.109).value,
|
self.assertEqual((ctypes.c_float(37.109).value, True),
|
||||||
obj.toFloat('37.109')[0])
|
obj.toFloat('37.109'))
|
||||||
|
|
||||||
def testToNumberDouble(self):
|
def testToNumberDouble(self):
|
||||||
obj = QLocale(QLocale.C)
|
obj = QLocale(QLocale.C)
|
||||||
self.assertEqual(ctypes.c_double(37.109).value,
|
self.assertEqual((ctypes.c_double(37.109).value, True),
|
||||||
obj.toDouble('37.109')[0])
|
obj.toDouble('37.109'))
|
||||||
|
|
||||||
|
def testToNumberShort(self):
|
||||||
|
obj = QLocale(QLocale.C)
|
||||||
|
self.assertEqual((ctypes.c_short(37).value, True),
|
||||||
|
obj.toShort('37'))
|
||||||
|
|
||||||
|
def testToNumberULongLong(self):
|
||||||
|
obj = QLocale(QLocale.C)
|
||||||
|
self.assertEqual((ctypes.c_ulonglong(37).value, True),
|
||||||
|
obj.toULongLong('37'))
|
||||||
|
|
||||||
|
def testToNumberULongLongNegative(self):
|
||||||
|
obj = QLocale(QLocale.C)
|
||||||
|
self.assert_(not obj.toULongLong('-37')[1])
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
|
||||||
|
|
@ -8,11 +8,9 @@ from PySide.QtCore import *
|
||||||
|
|
||||||
class TestQProcess (unittest.TestCase):
|
class TestQProcess (unittest.TestCase):
|
||||||
def testStartDetached(self):
|
def testStartDetached(self):
|
||||||
tuple_ = QProcess.startDetached("dir", [], os.getcwd())
|
value, pid = QProcess.startDetached("dir", [], os.getcwd())
|
||||||
self.assertEquals(tuple, tuple_.__class__)
|
self.assert_(isinstance(value, bool))
|
||||||
(value, pid) = tuple_
|
self.assert_(isinstance(pid, long))
|
||||||
self.assertEquals(bool, value.__class__)
|
|
||||||
self.assertEqual(long, pid.__class__)
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
|
||||||
|
|
@ -16,11 +16,31 @@ class MySize(QSize):
|
||||||
class QVariantToNumber(unittest.TestCase):
|
class QVariantToNumber(unittest.TestCase):
|
||||||
def testToNumberInt(self):
|
def testToNumberInt(self):
|
||||||
obj = QVariant('37')
|
obj = QVariant('37')
|
||||||
self.assertEqual(37, obj.toInt()[0])
|
self.assertEqual((37, True), obj.toInt())
|
||||||
|
|
||||||
|
def testToNumberLongLong(self):
|
||||||
|
obj = QVariant('37')
|
||||||
|
self.assertEqual((37, True), obj.toLongLong())
|
||||||
|
|
||||||
|
def testToNumberUInt(self):
|
||||||
|
obj = QVariant('37')
|
||||||
|
self.assertEqual((37, True), obj.toUInt())
|
||||||
|
|
||||||
|
def testToNumberUIntNegative(self):
|
||||||
|
obj = QVariant('-37')
|
||||||
|
self.assert_(not obj.toUInt()[1])
|
||||||
|
|
||||||
|
def testToNumberULongLong(self):
|
||||||
|
obj = QVariant('37')
|
||||||
|
self.assertEqual((37, True), obj.toULongLong())
|
||||||
|
|
||||||
|
def testToNumberULongLongNegative(self):
|
||||||
|
obj = QVariant('-37')
|
||||||
|
self.assert_(not obj.toULongLong()[1])
|
||||||
|
|
||||||
def testToNumberFloat(self):
|
def testToNumberFloat(self):
|
||||||
obj = QVariant('37.109')
|
obj = QVariant('37.109')
|
||||||
self.assertEqual(37.109, obj.toDouble()[0])
|
self.assertEqual((37.109, True), obj.toDouble())
|
||||||
|
|
||||||
class QVariantTypeName(unittest.TestCase):
|
class QVariantTypeName(unittest.TestCase):
|
||||||
def testTypeNameQString(self):
|
def testTypeNameQString(self):
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,16 @@ class TranslationTest(UsesQCoreApplication):
|
||||||
obj.setObjectName(obj.tr('Hello World!'))
|
obj.setObjectName(obj.tr('Hello World!'))
|
||||||
self.assertEqual(obj.objectName(), u'привет мир!')
|
self.assertEqual(obj.objectName(), u'привет мир!')
|
||||||
|
|
||||||
|
def testUtf8(self):
|
||||||
|
translator = QTranslator()
|
||||||
|
translator.load(os.path.join(self.trdir, 'trans_russian.qm'))
|
||||||
|
self.app.installTranslator(translator)
|
||||||
|
|
||||||
|
obj = QObject()
|
||||||
|
obj.setObjectName(obj.trUtf8('Hello World!'))
|
||||||
|
self.assertEqual(obj.objectName(), u'привет мир!')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue