aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.lima@openbossa.org>2010-06-03 15:34:17 -0300
committerHugo Parente Lima <hugo.lima@openbossa.org>2010-06-10 14:57:41 -0300
commite39bfefde9edda662f51eeaf9a482f209c7f1217 (patch)
treea4add52f8ca3460fcaed99c6d9c7fc810f341a49 /tests
parent24a944590663582df72aefd1929ec19ba3c6414f (diff)
Remove wrapper for classes: QString, QStringRef, QLatin1String, QStringMatcher, QChar and QLatin1Char.
Diffstat (limited to 'tests')
-rw-r--r--tests/QtCore/CMakeLists.txt6
-rw-r--r--tests/QtCore/buffer_test.py13
-rw-r--r--tests/QtCore/qbytearray_operator_iadd_test.py11
-rw-r--r--tests/QtCore/qbytearray_operator_test.py6
-rw-r--r--tests/QtCore/qchar_test.py59
-rw-r--r--tests/QtCore/qdatastream_test.py3
-rw-r--r--tests/QtCore/qenum_test.py4
-rw-r--r--tests/QtCore/qlatin1string_test.py21
-rw-r--r--tests/QtCore/qobject_property_test.py8
-rwxr-xr-xtests/QtCore/qstring_buffer_protocol_test.py20
-rw-r--r--tests/QtCore/qstring_operator_test.py161
-rw-r--r--tests/QtCore/qstring_test.py176
-rw-r--r--tests/QtCore/qstringlist_test.py171
-rw-r--r--tests/QtCore/qtextstream_test.py16
-rw-r--r--tests/QtCore/qvariant_pyobject_test.py7
-rw-r--r--tests/QtCore/qvariant_test.py19
-rw-r--r--tests/QtCore/translation_test.py4
-rw-r--r--tests/QtGui/qinputdialog_get_test.py2
-rw-r--r--tests/QtGui/qpixmap_test.py2
-rw-r--r--tests/QtGui/qstring_qkeysequence_test.py15
-rwxr-xr-xtests/QtSql/qsqldatabaseandqueries_test.py4
-rw-r--r--tests/phonon/capabilities_test.py4
-rwxr-xr-xtests/signals/decorators_test.py4
-rwxr-xr-xtests/signals/signal_object_test.py8
24 files changed, 45 insertions, 699 deletions
diff --git a/tests/QtCore/CMakeLists.txt b/tests/QtCore/CMakeLists.txt
index eef6ffe1..4a78bf6a 100644
--- a/tests/QtCore/CMakeLists.txt
+++ b/tests/QtCore/CMakeLists.txt
@@ -1,5 +1,4 @@
PYSIDE_TEST(blocking_signals_test.py)
-PYSIDE_TEST(buffer_test.py)
PYSIDE_TEST(child_event_test.py)
PYSIDE_TEST(deletelater_test.py)
PYSIDE_TEST(duck_punching_test.py)
@@ -14,7 +13,6 @@ PYSIDE_TEST(qbytearray_concatenation_operator_test.py)
PYSIDE_TEST(qbytearray_operator_iadd_test.py)
PYSIDE_TEST(qbytearray_operator_test.py)
PYSIDE_TEST(qbytearray_test.py)
-PYSIDE_TEST(qchar_test.py)
PYSIDE_TEST(qcoreapplication_instance_test.py)
PYSIDE_TEST(qdatastream_test.py)
PYSIDE_TEST(qdate_test.py)
@@ -24,7 +22,6 @@ PYSIDE_TEST(qfileinfo_test.py)
PYSIDE_TEST(qfile_test.py)
PYSIDE_TEST(qflags_test.py)
PYSIDE_TEST(qhandle_test.py)
-PYSIDE_TEST(qlatin1string_test.py)
PYSIDE_TEST(qlinef_test.py)
PYSIDE_TEST(qlocale_test.py)
PYSIDE_TEST(qmetaobject_test.py)
@@ -48,9 +45,6 @@ PYSIDE_TEST(qslot_object_test.py)
PYSIDE_TEST(qsrand_test.py)
PYSIDE_TEST(qstatemachine_test.py)
PYSIDE_TEST(qstate_test.py)
-PYSIDE_TEST(qstring_buffer_protocol_test.py)
-PYSIDE_TEST(qstringlist_test.py)
-PYSIDE_TEST(qstring_operator_test.py)
PYSIDE_TEST(qstring_test.py)
PYSIDE_TEST(qtext_codec_test.py)
PYSIDE_TEST(qtextstream_test.py)
diff --git a/tests/QtCore/buffer_test.py b/tests/QtCore/buffer_test.py
deleted file mode 100644
index 2917232a..00000000
--- a/tests/QtCore/buffer_test.py
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/usr/bin/python
-
-import unittest
-from PySide.QtCore import QString
-
-class BufferTest(unittest.TestCase):
- def testQByteArray(self):
- data = buffer("PySide")
- str = QString(data)
- self.assertEqual(data, str)
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/tests/QtCore/qbytearray_operator_iadd_test.py b/tests/QtCore/qbytearray_operator_iadd_test.py
index 168f22de..f92fc196 100644
--- a/tests/QtCore/qbytearray_operator_iadd_test.py
+++ b/tests/QtCore/qbytearray_operator_iadd_test.py
@@ -2,12 +2,12 @@
import unittest
import new
-from PySide.QtCore import QByteArray, QString
+from PySide.QtCore import *
from helper.docmodifier import DocModifier
class BaseQByteArrayOperatorIAdd(object):
'''Base class for QByteArray += operator tests.
-
+
Implementing classes should inherit from unittest.TestCase and implement
setUp, setting self.obj and self.orig_obj to the target QByteArray and original
one, respectively'''
@@ -41,13 +41,6 @@ class BaseQByteArrayOperatorIAdd(object):
self.assertEqual(self.obj, self.orig_obj + s)
self.assertEqual(self.obj.size(), self.orig_obj.size() + 1)
- def testQString(self):
- '''QByteArray += QString'''
- s = QString('dummy')
- self.obj += s
- self.assertEqual(self.obj, self.orig_obj + s)
- self.assertEqual(self.obj.size(), self.orig_obj.size() + s.size())
-
class NullQByteArrayOperatorIAdd(unittest.TestCase, BaseQByteArrayOperatorIAdd):
'''Test case for operator QByteArray += on null QByteArrays'''
diff --git a/tests/QtCore/qbytearray_operator_test.py b/tests/QtCore/qbytearray_operator_test.py
index 4a20c04c..662bc6e0 100644
--- a/tests/QtCore/qbytearray_operator_test.py
+++ b/tests/QtCore/qbytearray_operator_test.py
@@ -4,7 +4,7 @@
import unittest
-from PySide.QtCore import QByteArray, QString
+from PySide.QtCore import *
class QByteArrayOperatorEqual(unittest.TestCase):
'''TestCase for operator QByteArray == QByteArray'''
@@ -26,9 +26,9 @@ class QByteArrayOperatorEqual(unittest.TestCase):
self.assertEqual(QByteArray(string), string)
def testQString(self):
- #QByteArray(string) == QString(string)
+ #QByteArray(string) == string
string = 'another test string'
- self.assertEqual(QByteArray(string), QString(string))
+ self.assertEqual(QByteArray(string), string)
class QByteArrayOperatorAt(unittest.TestCase):
'''TestCase for operator QByteArray[]'''
diff --git a/tests/QtCore/qchar_test.py b/tests/QtCore/qchar_test.py
deleted file mode 100644
index a40724b0..00000000
--- a/tests/QtCore/qchar_test.py
+++ /dev/null
@@ -1,59 +0,0 @@
-
-'''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())
-
-
-class QCharCtorBigNumber(unittest.TestCase):
- '''QChar constructors receiving ints'''
-
- def testInt(self):
- '''QChar(int)'''
- codepoint = 512
- qchar = QChar(codepoint)
- reference = unichr(codepoint)
- self.assertEqual(qchar.unicode(), codepoint)
-
-
-class QCharCtorString(unittest.TestCase):
- '''QChar constructor receiving strings'''
-
- def testBasic(self):
- '''QChar(char)'''
- reference = 'a'
- qchar = QChar(reference)
- self.assertEqual(ord(reference), ord(qchar.toAscii()))
-
- def testError(self):
- '''QChar(char)'''
- reference = 'aaaaaa'
- self.assertRaises(TypeError, QChar, reference)
-
-
-if __name__ == '__main__':
- unittest.main()
-
diff --git a/tests/QtCore/qdatastream_test.py b/tests/QtCore/qdatastream_test.py
index d71ed2f2..e8091859 100644
--- a/tests/QtCore/qdatastream_test.py
+++ b/tests/QtCore/qdatastream_test.py
@@ -3,8 +3,7 @@
import unittest
-from PySide.QtCore import QDataStream, QString, QIODevice, QByteArray
-from PySide.QtCore import QBitArray, QDate, QTime, QDateTime, QLine, QChar
+from PySide.QtCore import *
def create_bitarray(string):
array = QBitArray(len(string))
diff --git a/tests/QtCore/qenum_test.py b/tests/QtCore/qenum_test.py
index e3f96386..d896ae65 100644
--- a/tests/QtCore/qenum_test.py
+++ b/tests/QtCore/qenum_test.py
@@ -3,7 +3,7 @@
import unittest
-from PySide.QtCore import QIODevice, QString, Qt, QVariant
+from PySide.QtCore import *
class TestEnum(unittest.TestCase):
@@ -18,7 +18,7 @@ class TestEnum(unittest.TestCase):
self.assertEqual(QIODevice.Unbuffered, 32)
def testToIntInFunction(self):
- self.assertEqual(QString.number(QIODevice.WriteOnly), "2")
+ self.assertEqual(str(int(QIODevice.WriteOnly)), "2")
class TestQFlags(unittest.TestCase):
def testToItn(self):
diff --git a/tests/QtCore/qlatin1string_test.py b/tests/QtCore/qlatin1string_test.py
deleted file mode 100644
index fdcf6ec9..00000000
--- a/tests/QtCore/qlatin1string_test.py
+++ /dev/null
@@ -1,21 +0,0 @@
-
-'''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()
-
diff --git a/tests/QtCore/qobject_property_test.py b/tests/QtCore/qobject_property_test.py
index 33df2ac9..d1f12b34 100644
--- a/tests/QtCore/qobject_property_test.py
+++ b/tests/QtCore/qobject_property_test.py
@@ -3,7 +3,7 @@
import unittest
-from PySide.QtCore import QObject, QVariant, QString
+from PySide.QtCore import *
class PropertyCase(unittest.TestCase):
'''Test case for QObject properties'''
@@ -41,14 +41,14 @@ class PropertyCase(unittest.TestCase):
# QVariant.toInt has a bool* arg in C++, so returns a tuple
self.assertEqual(obj.property('dummy').toInt(), (42, True))
- def testQStringProperty(self):
+ def testStringProperty(self):
obj = QObject()
- self.assert_(not obj.setProperty('dummy', QString('data')))
+ self.assert_(not obj.setProperty('dummy', 'data'))
prop = obj.property('dummy')
self.assert_(isinstance(prop, QVariant))
self.assert_(prop.isValid())
- self.assertEqual(obj.property('dummy').toString(), QString('data'))
+ self.assertEqual(obj.property('dummy').toString(), 'data')
def testImplicitQVariantProperty(self):
obj = QObject()
diff --git a/tests/QtCore/qstring_buffer_protocol_test.py b/tests/QtCore/qstring_buffer_protocol_test.py
deleted file mode 100755
index f8475d09..00000000
--- a/tests/QtCore/qstring_buffer_protocol_test.py
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-'''Tests QString implementation of Python buffer protocol'''
-
-import unittest
-
-from os.path import isdir
-from PySide.QtCore import QString
-
-class QStringBufferProtocolTest(unittest.TestCase):
- '''Tests QString implementation of Python buffer protocol'''
-
- def testQStringBufferProtocol(self):
- #Tests QString implementation of Python buffer protocol using the os.path.isdir
- #function which an unicode object or other object implementing the Python buffer protocol
- isdir(QString('/tmp'))
-
-if __name__ == '__main__':
- unittest.main()
-
diff --git a/tests/QtCore/qstring_operator_test.py b/tests/QtCore/qstring_operator_test.py
deleted file mode 100644
index 6d7ae314..00000000
--- a/tests/QtCore/qstring_operator_test.py
+++ /dev/null
@@ -1,161 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-'''Test cases for QString operators'''
-
-import unittest
-
-from PySide.QtCore import QString, QByteArray
-
-class QStringOperatorEqual(unittest.TestCase):
- '''TestCase for operator QString == QString'''
-
- def testDefault(self):
- #QString() == QString()
- obj1 = QString()
- obj2 = QString()
- self.assertEqual(obj1, obj2)
-
- def testSimple(self):
- #QString(some_string) == QString(some_string)
- string = 'egg snakes'
- self.assertEqual(QString(string), QString(string))
-
- def testUnicode(self):
- #QString(unicode) == QString(unicode)
- string = u'àâãá'
- self.assertEqual(QString(string), QString(string))
-
- def testPyString(self):
- #QString(string) == string
- string = 'my test string'
- self.assertEqual(QString(string), string)
- self.assertEqual(string, QString(string))
-
- def testPyUnicodeString(self):
- #QString(unicode) == unicode
- string = u'àâãá'
- self.assertEqual(QString(string), string)
- self.assertEqual(string, unicode(QString(string)))
-
- def testQByteArray(self):
- #QString(string) == QByteArray(string)
- string = 'another test string'
- self.assertEqual(QString(string), QByteArray(string))
-
-
-class QStringOperatorAtSetter(unittest.TestCase):
- '''Test case for operator QString[] - __setitem__'''
-
- def testSetterString(self):
- '''QString[x] = pythonstring'''
- obj = QString('123456')
- obj[1] = '0'
- self.assertEqual(obj, QString('103456'))
-
- def testSetterStringLarge(self):
- '''QString[x] = pythonstring (larget than 1 char)'''
- obj = QString('123456')
- obj[3] = 'abba'
- self.assertEqual(obj, QString('123abba56'))
-
- def testSetterQString(self):
- '''QString[x] = QString'''
- obj = QString('123456')
- obj[3] = QString('string')
- self.assertEqual(obj, QString('123string56'))
-
- def testSetterQByteArray(self):
- '''QString[x] = qbytearray'''
- obj = QString('123456')
- obj[3] = QByteArray('array')
- self.assertEqual(obj, QString('123array56'))
-
-
-class QStringOperatorAtSetterNegativeIndex(unittest.TestCase):
- '''Test case for QString[] - __setitem__ - for negative index'''
-
- def testSetterNegativeIndex(self):
- '''QString[x] = string - negative index'''
- obj = QString('123456')
- obj[-3] = 'array'
- self.assertEqual(obj, QString('123array56'))
-
-
-class QStringOperatorAtSetterLargeIndex(unittest.TestCase):
- '''Test case for QString[] - __setitem__ - for 'overflown' index'''
-
- def testSetterLargeIndexEmpty(self):
- '''QString[x] = somestring - Overflow index on empty string'''
- # should pad with spaces if the index is larger
- obj = QString('')
- obj[2] = 'a'
- self.assertEqual(obj, QString(' a'))
-
- def testSetterLargeIndexNormal(self):
- '''QString[x] = somestring - Overflow index on normal string'''
- # should pad with spaces if the index is larger
- obj = QString('mystring')
- obj[10] = 'normal'
- self.assertEqual(obj, QString('mystring normal'))
-
-
-class QStringOperatorAt(unittest.TestCase):
- '''TestCase for operator QString[] - __getitem__'''
-
- def testInRange(self):
- #QString[x] where x is a valid index
- string = 'abcdefgh'
- obj = QString(string)
-
- for i in range(len(string)):
- self.assertEqual(obj[i], string[i])
-
- def testInRangeReverse(self):
- #QString[x] where x is a valid index (reverse order)
- string = 'abcdefgh'
- obj = QString(string)
-
- for i in range(len(string)-1, 0, -1):
- self.assertEqual(obj[i], string[i])
-
-
- def testInRangeUnicode(self):
- #QString[x] where x is a valid index (unicode)
- string = u'àâãá'
- obj = QString(string)
-
- for i in range(len(string)):
- self.assertEqual(obj[i], string[i])
-
- def testInRangeUnicodeReverse(self):
- #QString[x] where x is a valid index (unicode) (reverse order)
- string = u'àâãá'
- obj = QString(string)
-
- for i in range(len(string)-1, 0, -1):
- self.assertEqual(obj[i], string[i])
-
- def testOutOfRange(self):
- #QString[x] where x is out of index
- string = '1234567'
- obj = QString(string)
- self.assertRaises(IndexError, lambda :obj[len(string)])
-
- def testReturnQString(self):
- #QString[x] must return a QString
- string = QString('123456')
- data = string[0]
- self.assert_(isinstance(data, QString))
-
-class QStringOperatorAdd(unittest.TestCase):
- '''TestCase for operator QString[]'''
-
- def testOperatorAdd(self):
- str1 = '123'
- str2 = QString('456')
- self.assertEquals('123456', str1 + str2)
- self.assertEquals('456123', str2 + str1)
-
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/tests/QtCore/qstring_test.py b/tests/QtCore/qstring_test.py
index 3f0fb493..fbaa6d44 100644
--- a/tests/QtCore/qstring_test.py
+++ b/tests/QtCore/qstring_test.py
@@ -6,173 +6,19 @@ import unittest
import ctypes
import sys
-from PySide.QtCore import QString, QByteArray, QObject
-
-class QStringToNumber(unittest.TestCase):
- def testReturnValueTypes(self):
- obj = QString('37')
- val, ok = obj.toInt()
- self.assertEqual(type(val), int)
- self.assertEqual(type(ok), bool)
-
- def testToNumberInt(self):
- obj = QString('37')
- self.assertEqual((37, True), obj.toInt())
-
- def testToNumberLong(self):
- obj = QString('3700000')
- self.assertEqual((3700000, True), obj.toInt())
-
- def testToNumberShort(self):
- obj = QString('33')
- self.assertEqual((ctypes.c_short(33).value, True), obj.toShort())
-
- def testToNumberShortNegative(self):
- obj = QString('-4')
- self.assertEqual((ctypes.c_short(-4).value, True), obj.toShort())
-
- def testToNumberShortOverflow(self):
- obj = QString('1000000')
- self.assertEqual(False, obj.toShort()[1])
-
- def testToNumberUInt(self):
- obj = QString('33')
- self.assertEqual((ctypes.c_uint(33).value, True), obj.toUInt())
-
- def testToNumberUIntNegative(self):
- obj = QString('-4')
- self.assertEqual(False, obj.toUInt()[1])
-
- def testToNumberUIntOverflow(self):
- obj = QString('10000000000000')
- self.assertEqual(False, obj.toUInt()[1])
-
- def testToNumberULong(self):
- obj = QString('33')
- self.assertEqual((ctypes.c_ulong(33).value, True), obj.toULong())
-
- def testToNumberULongNegative(self):
- obj = QString('-4')
- self.assertEqual(False, obj.toULong()[1])
-
- def testToNumberUShort(self):
- obj = QString('33')
- self.assertEqual((ctypes.c_ushort(33).value, True), obj.toUShort())
-
- def testToNumberUShortLarge(self):
- obj = QString('128')
- self.assertEqual((ctypes.c_ushort(128).value, True), obj.toUShort())
-
- def testToNumberUShortOverflow(self):
- obj = QString('205000')
- self.assertEqual(False, obj.toUShort()[1])
-
- def testToNumberUShortNegative(self):
- obj = QString('-4')
- self.assertEqual(False, obj.toUShort()[1])
-
- def testToNumberIntUsingHex(self):
- obj = QString('2A')
- self.assertEquals((0, False), obj.toInt())
- self.assertEqual((int(str(obj), 16), True), obj.toInt(16))
-
- def testToNumberIntUsingHex(self):
- obj = QString('101010')
- self.assertEqual((int(str(obj), 2), True), obj.toInt(2))
-
- def testToNumberFloat(self):
- obj = QString('37.109')
- self.assertEqual(ctypes.c_float(37.109).value,
- obj.toFloat()[0])
-
- def testToNumberDouble(self):
- obj = QString('37.109')
- self.assertEqual(ctypes.c_double(37.109).value,
- obj.toDouble()[0])
-
- def testToULongLong(self):
- obj = QString('37109')
- self.assertEqual(ctypes.c_ulong(37109).value,
- obj.toULongLong()[0])
+from PySide.QtCore import *
class QStringConstructor(unittest.TestCase):
'''Test case for QString constructors'''
def testQStringDefault(self):
- #QString()
- obj1 = QString()
- obj2 = QString()
-
- self.assertEqual(obj1, obj2)
-
- def testNullQString(self):
- s = QString(None)
- self.assertTrue(s.isNull())
-
- def testQStringFromPy(self):
- #QString(const char*)
- sample = 'a new string'
- obj1 = QString(sample)
- obj2 = QString(sample)
- self.assertEqual(obj1, obj2)
-
- def testQStringFromUnicode(self):
- sample = u'áâãà'
- obj1 = QString(sample)
- obj2 = QString(sample)
- self.assertEqual(obj1, obj2)
- self.assertEqual(obj1, sample)
- self.assertEqual(obj2, sample)
-
- def testQStringFromByteArray(self):
- # QByteArray(const char *) must be working
- sample = QByteArray('foo')
- obj1 = QString(sample)
- obj2 = QString(sample)
- self.assertEqual(obj1, obj2)
-
- def testQStringArg(self):
- a = QString("%1 %2 %3").arg(1).arg("two").arg(3.14)
- self.assertEquals("1 two 3.14", str(a))
-
- def testQStringArgNegative(self):
- a = QString("%1").arg(-20)
- self.assertEquals("-20", str(a))
-
-
-class QStringComparison(unittest.TestCase):
- '''Test case for comparison to python strings'''
-
- def testComparePyString(self):
- #Compare QStrings and Python strings.
- py = ''
- qstr = QString()
- self.assertEqual(py, qstr)
-
- py = 'The quick brown fox jumps over the lazy dog'
- qstr = QString(py)
- self.assertEqual(py, qstr)
-
-class QStringRange(unittest.TestCase):
- '''Test case for ranges in python strings'''
-
- def testSimpleRange(self):
- #Test open start and open end intervals
- py = 'The quick brown fox jumps over the lazy dog'
- qstr = QString(py)
- self.assertEqual(py[5:], qstr[5:])
- self.assertEqual(py[:7], qstr[:7])
-
-class QStringIndexOf(unittest.TestCase):
- def testEmpty(self):
- string = QString()
- self.assertEqual(string.indexOf(QString("aaa")), -1)
- self.assertEqual(string.indexOf(QString()), 0)
-
- def testString(self):
- string = QString("the quick brown fox")
- self.assertEqual(string.indexOf("quick", 0), 4)
-
+ obj = QObject()
+ obj.setObjectName('foo')
+ self.assertEqual(obj.objectName(), u'foo')
+ obj.setObjectName(u'áâãà')
+ self.assertEqual(obj.objectName(), u'áâãà')
+ obj.setObjectName(None)
+ self.assertEqual(obj.objectName(), u'')
class QStringImplicitConvertion(unittest.TestCase):
'''Implicit conversions for QString'''
@@ -181,12 +27,8 @@ class QStringImplicitConvertion(unittest.TestCase):
'''QString implicitly conversion: QByteArray'''
obj = QObject()
obj.setObjectName(QByteArray('foobar'))
- self.assertEqual(obj.objectName(), QString('foobar'))
+ self.assertEqual(obj.objectName(), u'foobar')
-class QStringHash(unittest.TestCase):
- def testHash(self):
- self.assertEqual(hash("key"), hash(QString("key")))
- self.assertEqual(hash(u"aéióu"), hash(QString(u"aéióu")))
if __name__ == '__main__':
unittest.main()
diff --git a/tests/QtCore/qstringlist_test.py b/tests/QtCore/qstringlist_test.py
deleted file mode 100644
index 03105168..00000000
--- a/tests/QtCore/qstringlist_test.py
+++ /dev/null
@@ -1,171 +0,0 @@
-
-# -*- coding: utf-8 -*-
-
-'''Test cases for QStringList'''
-
-import unittest
-from random import shuffle
-
-from PySide.QtCore import QStringList, QString
-
-from helper import random_string
-
-class UsesManyStrings(unittest.TestCase):
- '''Helper class to setup a list of strings and QStrings'''
- def setUp(self):
- #Creates a list of strings and python strings
- self.size = 10
- # List of Python strings
- self.samples = [random_string() for x in range(self.size)]
- # List of QStrings
- self.strings = map(QString, self.samples)
-
- self.obj = QStringList(self.strings)
-
-
-class TestConstructorBasic(unittest.TestCase):
- '''Basic constructor test'''
-
- def testEmpty(self):
- #QStringList() - default constructor
- obj = QStringList()
- self.assert_(isinstance(obj, QStringList))
-
- def testQString(self):
- #QStringList(QString)
- qstr = QString('aaaa')
- obj = QStringList(qstr)
- self.assert_(isinstance(obj, QStringList))
-
- def testPyString(self):
- #QStringList(python_string) constructor
- string = 'forty two'
- obj = QStringList(string)
- self.assert_(isinstance(obj, QStringList))
-
- def testPyStringUnicode(self):
- #QStringList(unicode python_string) constructor
- string = 'Nação Zumbi'
- obj = QStringList(string)
- self.assert_(isinstance(obj, QStringList))
-
-
-class TestConstructorList(UsesManyStrings):
- '''Test case for QStringList(List) constructor'''
-
- def testListQString(self):
- #QStringList([QString]) constructor
- obj = QStringList(self.strings)
- self.assert_(isinstance(obj, QStringList))
-
- def testListPyString(self):
- #QStringList([python_string]) constructor
- obj = QStringList(self.samples)
- self.assert_(isinstance(obj, QStringList))
-
- def testListMixed(self):
- #QStringList([python_string and QString]) mixed constructor
- mixed = self.samples + self.strings
- shuffle(mixed)
- obj = QStringList(mixed)
- self.assert_(isinstance(obj, QStringList))
-
- def testCopyList(self):
- #QStringList(QStringList(list)) - copy constructor
- obj = QStringList(self.strings)
- obj2 = QStringList(obj)
- self.assert_(isinstance(obj2, QStringList))
- self.assertEqual(obj, obj2)
-
-
-class TestComparison(unittest.TestCase):
- '''Test case for comparison of QStringLists'''
-
- def testEqual(self):
- #QStringList == QStringList
- string = QString('aaaabvbbcccedde')
- obj1 = QStringList(string)
- obj2 = QStringList(string)
- self.assertEqual(obj1, obj2)
-
-
-class TestIndexing(unittest.TestCase):
- '''Test case for indexing through []'''
- def testInvalidIndexEmpty(self):
- #QStringList[x] for empty list
- obj = QStringList()
- self.assertRaises(IndexError, lambda:obj[0])
-
- def testInvalidIndexQString(self):
- #QStringList[1] raising IndexError for QStringList(QString)
- obj = QStringList(QString('aaaaa'))
- self.assertRaises(IndexError, lambda:obj[1])
-
- def testValidIndexQString(self):
- #QStringList[0] not raising IndexError for QStringList(QString)
- string = QString('abcdefg')
- obj = QStringList(string)
- self.assertEqual(obj[0], string)
-
- def testNegativeIndexing(self):
- #QStringList[-1] not raising IndexError for QStringList(QString)
- string = QString('abcdefg')
- obj = QStringList(string)
- self.assertEqual(obj[-1], string)
-
-
-class TestListIndexing(UsesManyStrings):
- '''Test case for indexing QStringList longer than 1 string'''
-
- def testValid(self):
- #QStringList[] for valid indexes
- for i in range(self.size):
- self.assertEqual(self.strings[i], self.obj[i])
-
- def testNegativeValid(self):
- #QStringList[] for valid indexes
- for i in range(-1, -self.size, -1):
- self.assertEqual(self.strings[i], self.obj[i])
-
- def testInvalid(self):
- #QStringList[] for invalid negative indexes
- self.assertRaises(IndexError, lambda : self.obj[self.size])
- self.assertRaises(IndexError, lambda : self.obj[-(self.size+1)])
-
-
-class TestSlicing(UsesManyStrings):
- '''Test case for slicing a QStringList'''
-
- def testSlicing(self):
- #QStringList slicing
- for i in range(self.size):
- self.assertEqual(self.obj[i:], self.strings[i:])
- self.assertEqual(self.obj[:i], self.strings[:i])
- for j in range(i):
- self.assertEqual(self.obj[j:i], self.strings[j:i])
-
- for i in range(-1, -self.size, -1):
- self.assertEqual(self.obj[:i], self.strings[:i])
-
-
-class TestShiftOperator(UsesManyStrings):
- '''Test case for QStringList lshift operator'''
-
- def testShiftOperator(self):
- #QStringList lshift
- a = QStringList()
- a << "a" << "b" << "c";
- self.assertEquals(3, a.count())
- b = ["1", "2", "3"]
- c = ["4", "5", "6"]
- a << b << c
- self.assertEquals(9, a.count())
-
- def testShiftOperator(self):
- #QStringList lshift
- a = QStringList()
- b = ["1", 2, "3"]
- self.assertRaises(TypeError, a.__lshift__, b)
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/tests/QtCore/qtextstream_test.py b/tests/QtCore/qtextstream_test.py
index 13dc6516..a8f561c0 100644
--- a/tests/QtCore/qtextstream_test.py
+++ b/tests/QtCore/qtextstream_test.py
@@ -3,8 +3,7 @@
import unittest
-from PySide.QtCore import QTextStream, QIODevice, QString, QByteArray
-from PySide.QtCore import QTextCodec, QFile
+from PySide.QtCore import *
class QTextStreamShiftTest(unittest.TestCase):
@@ -16,18 +15,11 @@ class QTextStreamShiftTest(unittest.TestCase):
def testNumber(self):
'''QTextStream << number'''
- self.write << QString('4')
+ self.write << '4'
self.write.flush()
res = self.read.readLine()
- self.assert_(isinstance(res, QString))
- self.assertEqual(res, QString('4'))
-
- def testString(self):
- self.write << QString('Test_it!')
- self.write.flush()
- res = QString()
- self.read >> res
- self.assertEqual(res, QString('Test_it!'))
+ self.assert_(isinstance(res, unicode))
+ self.assertEqual(res, '4')
class QTextStreamGetSet(unittest.TestCase):
diff --git a/tests/QtCore/qvariant_pyobject_test.py b/tests/QtCore/qvariant_pyobject_test.py
index 82da5556..2000a019 100644
--- a/tests/QtCore/qvariant_pyobject_test.py
+++ b/tests/QtCore/qvariant_pyobject_test.py
@@ -3,19 +3,17 @@
import unittest
-from PySide.QtCore import QSize, QVariant, QString
+from PySide.QtCore import *
class Dummy(object):
'''Pure python sample class'''
pass
-
class MySize(QSize):
'''Extended class'''
pass
-
class QVariantPurePython(unittest.TestCase):
'''QVariant + pure python classes'''
@@ -26,7 +24,6 @@ class QVariantPurePython(unittest.TestCase):
# inherited type name from other binding
self.assertEqual('PyQt_PyObject', obj.typeName())
-
class QVariantInheritedPython(unittest.TestCase):
'''QVariant + classes inherited from C++'''
@@ -63,7 +60,7 @@ class QVariantToPyObject(unittest.TestCase):
'''QVariant(python string).toPyObject() return an equal QString'''
d = 'abc'
obj = QVariant('abc')
- self.assert_(isinstance(obj.toPyObject(), QString))
+ self.assert_(isinstance(obj.toPyObject(), unicode))
self.assertEqual(d, obj.toPyObject())
diff --git a/tests/QtCore/qvariant_test.py b/tests/QtCore/qvariant_test.py
index 5c23b404..6be7b810 100644
--- a/tests/QtCore/qvariant_test.py
+++ b/tests/QtCore/qvariant_test.py
@@ -5,7 +5,7 @@
import unittest
import sys
-from PySide.QtCore import QSize, QVariant, QByteArray, QStringList, QString
+from PySide.QtCore import *
class QVariantToNumber(unittest.TestCase):
@@ -50,11 +50,6 @@ class QVariantToNumber(unittest.TestCase):
class QVariantTypeName(unittest.TestCase):
'''QVariant.typeName()'''
- def testTypeNameQString(self):
- '''QVariant(QString).typeName()'''
- obj = QVariant(QString('aaaa'))
- self.assertEqual('QString', obj.typeName())
-
def testTypeNameString(self):
'''QVariant(PyString).typeName()'''
obj = QVariant('aaaa')
@@ -96,18 +91,6 @@ class QVariantTypeName(unittest.TestCase):
obj = QVariant(['aaa', 'bbb', 'ccc', 'dddd'])
self.assertEqual('QVariantList', obj.typeName())
- obj = QVariant([QString('aaa'), QString('bbb'),
- QString('ccc'), QString('dddd')])
- self.assertEqual('QVariantList', obj.typeName())
-
- def testTypeNameQStringList(self):
- '''QVariant(QStringList).typeName()'''
- obj = QVariant(QStringList())
- self.assertEqual('QStringList', obj.typeName())
- obj = QVariant(QStringList(['aaa', 'bbb', 'ccc']))
- self.assertEqual('QStringList', obj.typeName())
-
-
class QVariantConstructor(unittest.TestCase):
'''More qvariant constructions'''
diff --git a/tests/QtCore/translation_test.py b/tests/QtCore/translation_test.py
index 870c8c50..6b75bee3 100644
--- a/tests/QtCore/translation_test.py
+++ b/tests/QtCore/translation_test.py
@@ -5,7 +5,7 @@
import os
import unittest
-from PySide.QtCore import QObject, QTranslator, QCoreApplication, QString
+from PySide.QtCore import *
from helper import UsesQCoreApplication
@@ -54,7 +54,7 @@ class TranslationTest(UsesQCoreApplication):
def testTranslateWithNoneDisambiguation(self):
value = 'String here'
obj = QCoreApplication.translate('context', value, None, QCoreApplication.UnicodeUTF8)
- self.assert_(isinstance(obj, QString))
+ self.assert_(isinstance(obj, unicode))
self.assertEqual(obj, value)
if __name__ == '__main__':
diff --git a/tests/QtGui/qinputdialog_get_test.py b/tests/QtGui/qinputdialog_get_test.py
index c75f7125..ce3a60df 100644
--- a/tests/QtGui/qinputdialog_get_test.py
+++ b/tests/QtGui/qinputdialog_get_test.py
@@ -15,7 +15,7 @@ class TestInputDialog(TimedQApplication):
self.assertEquals(QtGui.QInputDialog.getInteger(None, "title", "label"), (0, False))
def testGetItem(self):
- (item, bool) = QtGui.QInputDialog.getItem(None, "title", "label", QtCore.QStringList(["1", "2", "3"]))
+ (item, bool) = QtGui.QInputDialog.getItem(None, "title", "label", ["1", "2", "3"])
self.assertEquals(str(item), "1")
def testGetText(self):
diff --git a/tests/QtGui/qpixmap_test.py b/tests/QtGui/qpixmap_test.py
index 48140946..7ba7454d 100644
--- a/tests/QtGui/qpixmap_test.py
+++ b/tests/QtGui/qpixmap_test.py
@@ -16,7 +16,7 @@ class QPixmapTest(UsesQApplication):
self.assert_(pixmap.size().height(), 20)
def testQStringConstructor(self):
- pixmap = QPixmap(QString("Testing!"))
+ pixmap = QPixmap("Testing!")
def testQVariantConstructor2(self):
v = QVariant(QPixmap())
diff --git a/tests/QtGui/qstring_qkeysequence_test.py b/tests/QtGui/qstring_qkeysequence_test.py
index 1f435e6e..15db935a 100644
--- a/tests/QtGui/qstring_qkeysequence_test.py
+++ b/tests/QtGui/qstring_qkeysequence_test.py
@@ -5,7 +5,7 @@
import unittest
from helper import UsesQApplication
-from PySide.QtCore import QString
+from PySide.QtCore import *
from PySide.QtGui import QKeySequence, QAction
class QStringQKeySequenceTest(UsesQApplication):
@@ -14,21 +14,12 @@ class QStringQKeySequenceTest(UsesQApplication):
def testQStringFromQKeySequence(self):
'''Creates a QString from a QKeySequence.'''
keyseq = 'Ctrl+A'
- a = QString(QKeySequence(keyseq))
+ a = QKeySequence(keyseq)
self.assertEqual(a, keyseq)
- def testQStringAsQKeySequence(self):
- '''Passes a QString to an argument expecting a QKeySequence.'''
- keyseq = QString('Ctrl+A')
- action = QAction(None)
- action.setShortcut(keyseq)
- shortcut = action.shortcut()
- self.assert_(isinstance(shortcut, QKeySequence))
- self.assertEqual(shortcut.toString(), keyseq)
-
def testPythonStringAsQKeySequence(self):
'''Passes a Python string to an argument expecting a QKeySequence.'''
- keyseq = 'Ctrl+A'
+ keyseq = u'Ctrl+A'
action = QAction(None)
action.setShortcut(keyseq)
shortcut = action.shortcut()
diff --git a/tests/QtSql/qsqldatabaseandqueries_test.py b/tests/QtSql/qsqldatabaseandqueries_test.py
index 49f22093..2d5a0a3e 100755
--- a/tests/QtSql/qsqldatabaseandqueries_test.py
+++ b/tests/QtSql/qsqldatabaseandqueries_test.py
@@ -5,14 +5,14 @@ import sys
import unittest
from PySide import QtSql
-from PySide.QtCore import QVariant, QString
+from PySide.QtCore import *
class SqlDatabaseCreationDestructionAndQueries(unittest.TestCase):
'''Test cases for QtSql database creation, destruction and queries'''
def setUp(self):
#Acquire resources
- self.assertFalse(QtSql.QSqlDatabase.drivers().isEmpty(), "installed Qt has no DB drivers")
+ self.assertFalse(not QtSql.QSqlDatabase.drivers(), "installed Qt has no DB drivers")
self.assertTrue("QSQLITE" in QtSql.QSqlDatabase.drivers(), "\"QSQLITE\" driver not available in this Qt version")
self.db = QtSql.QSqlDatabase.addDatabase("QSQLITE")
self.db.setDatabaseName(":memory:")
diff --git a/tests/phonon/capabilities_test.py b/tests/phonon/capabilities_test.py
index 5f4b7da8..99c64737 100644
--- a/tests/phonon/capabilities_test.py
+++ b/tests/phonon/capabilities_test.py
@@ -1,7 +1,7 @@
import unittest
-from PySide.QtCore import QString
+from PySide.QtCore import *
from PySide import phonon
from helper import UsesQCoreApplication
@@ -36,7 +36,7 @@ class CapabilitiesTest(UsesQCoreApplication):
# TODO Improve this test
mimeTypes = phonon.Phonon.BackendCapabilities.availableMimeTypes()
for mime in mimeTypes:
- self.assert_(isinstance(mime, QString))
+ self.assert_(isinstance(mime, unicode))
def testAudioEffects(self):
# TODO Improve this test
diff --git a/tests/signals/decorators_test.py b/tests/signals/decorators_test.py
index db068d00..db32ec9b 100755
--- a/tests/signals/decorators_test.py
+++ b/tests/signals/decorators_test.py
@@ -24,7 +24,7 @@ class MyObject(QObject):
def foo(self):
self._slotCalledCount = self._slotCalledCount + 1
- @Slot(QString, int)
+ @Slot(unicode, int)
def mySlot4(self, a, b):
self._slotCalledCount = self._slotCalledCount + 1
@@ -41,7 +41,7 @@ class StaticMetaObjectTest(unittest.TestCase):
self.assert_(m.indexOfSlot('mySlot2(int)') > 0)
self.assert_(m.indexOfSlot('mySlot2(QString)') > 0)
self.assert_(m.indexOfSlot('mySlot3()') > 0)
- self.assert_(m.indexOfSlot('mySlot4(QString,int)') > 0)
+ self.assert_(m.indexOfSlot('mySlot4(unicode,int)') > 0)
def testEmission(self):
o = MyObject()
diff --git a/tests/signals/signal_object_test.py b/tests/signals/signal_object_test.py
index 614c0e60..d36665cf 100755
--- a/tests/signals/signal_object_test.py
+++ b/tests/signals/signal_object_test.py
@@ -11,8 +11,8 @@ class MyObject(QTimer):
sig1 = Signal()
sig2 = Signal(int, name='rangeChanged')
sig3 = Signal(int)
- sig4 = Signal((int,), (QString,))
- sig5 = Signal((QString,), (int,))
+ sig4 = Signal((int,), (unicode,))
+ sig5 = Signal((unicode,), (int,))
@Slot(int)
@@ -50,8 +50,8 @@ class SignalObjectTest(UsesQCoreApplication):
def testDictOperator(self):
o = MyObject()
- o.sig4[QString].connect(o.slotString)
- o.sig4[QString].emit("PySide")
+ o.sig4[unicode].connect(o.slotString)
+ o.sig4[unicode].emit("PySide")
self.assertEqual(o._s, "PySide")
def testGeneretedSignal(self):