Created new unittest model.
Separete unittest for module.
Only run unittest for compiled modules.
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org>,
Luciano Wolf <luciano.wolf@openbossa.org>
This commit is contained in:
parent
471486732b
commit
ab918abc1e
211 changed files with 241 additions and 79 deletions
59
tests/QtCore/qchar_test.py
Normal file
59
tests/QtCore/qchar_test.py
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
|
||||
'''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()
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue