def setUp(self): self.temp_file = tempfile.NamedTemporaryFile(delete=False) self.temp_file.close() self.f = QtCore.QFile(self.temp_file.name) self.f.open(QtCore.QIODevice.WriteOnly) self.strings = (py3k.unicode_('foo'), py3k.unicode_('bar')) self.stream = QtCore.QTextStream(self.f)
def testSetValueWithLongInts(self): s = QtCore.QSettings() s.setValue("test", [(py3k.unicode_('36/37'), 65824, 69888), (py3k.unicode_('38/39'), 4294902272, 4294906368), (py3k.unicode_('40/41'), 4294902528, 4294906624), (py3k.unicode_('new'), 65824, 69888)]) val = s.value("test")
def testQStringDefault(self): obj = QObject() obj.setObjectName('foo') self.assertEqual(obj.objectName(), py3k.unicode_('foo')) obj.setObjectName(py3k.unicode_('áâãà')) self.assertEqual(obj.objectName(), py3k.unicode_('áâãà')) obj.setObjectName(None) self.assertEqual(obj.objectName(), py3k.unicode_(''))
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(), py3k.unicode_('привет мир!'))
def testPythonStringAsQKeySequence(self): '''Passes a Python string to an argument expecting a QKeySequence.''' keyseq = py3k.unicode_('Ctrl+A') action = QAction(None) action.setShortcut(keyseq) shortcut = action.shortcut() self.assert_(isinstance(shortcut, QKeySequence)) self.assertEqual(shortcut.toString(), keyseq)
def testUtf8(self): translator = QTranslator() translator.load(os.path.join(self.trdir, 'trans_russian.qm')) self.app.installTranslator(translator) obj = QObject() obj.setObjectName(obj.tr('Hello World!')) self.assertEqual(obj.objectName(), py3k.unicode_('привет мир!'))
def testIt(self): a = QByteArray(py3k.unicode_('hi 猫').encode('utf-8')) if py3k.IS_PY3K: self.assertEqual( repr(a), "PySide2.QtCore.QByteArray(b'hi \\xe7\\x8c\\xab')") else: self.assertEqual( repr(a), "PySide2.QtCore.QByteArray('hi \\xe7\\x8c\\xab')")
def testLatin(self): #Set string value to Latin translator = QTranslator() translator.load(os.path.join(self.trdir, 'trans_latin.qm')) self.app.installTranslator(translator) obj = QObject() obj.setObjectName(obj.tr('Hello World!')) self.assertEqual(obj.objectName(), py3k.unicode_('Orbis, te saluto!'))
def testQCharNull(self): '''QDataStream <<>> QChar - null''' self.stream.writeQChar(None) res = self.read_stream.readQChar() self.assertEqual(res, py3k.unicode_('\x00'))
def testQStringNull(self): '''QDataStream <<>> QString - null''' self.stream.writeQString(None) res = self.read_stream.readQString() self.assertEqual(res, py3k.unicode_(''))
def testQStringEmpty(self): '''QDataStream <<>> QString - empty''' self.stream.writeQString('') res = self.read_stream.readQString() self.assertEqual(res, py3k.unicode_(''))
def testSetUnicodeRetrieveUnicode(self): #Set Python unicode string and retrieve unicode obj = QObject() obj.setObjectName(py3k.unicode_('ümlaut')) self.assertEqual(obj.objectName(), py3k.unicode_('ümlaut'))
def mimeData(self,indexes): self.__mimedata = super(MyItemModel,self).mimeData(indexes) self.__mimedata.setData(py3k.unicode_('application/my-form'), 'hi') return self.__mimedata
def testUnicode(self): name = py3k.unicode_('não') #FIXME Strange error on upstream when using equal(name, obj) obj = QObject() obj.setObjectName(name) self.assertEqual(obj.objectName(), name)
def mimeData(self, indexes): self.__mimedata = super(MyItemModel, self).mimeData(indexes) self.__mimedata.setData(py3k.unicode_('application/my-form'), py3k.b('hi')) return self.__mimedata
def mimeTypes(self): mtypes = super(MyItemModel, self).mimeTypes() mtypes.append(py3k.unicode_('application/my-form')) return mtypes
def testIt(self): self.sock.write(py3k.unicode_('quit'))
def testSetRegularStringRetrieveUnicode(self): #Set regular Python string retrieve unicode obj = QObject() obj.setObjectName('test') self.assertEqual(obj.objectName(), py3k.unicode_('test'))
def testQStringValid(self): '''QDataStream <<>> QString - valid''' self.stream.writeQString('Ka-boom') res = self.read_stream.readQString() self.assertEqual(res, py3k.unicode_('Ka-boom'))
def mimeTypes(self): mtypes = super(MyItemModel,self).mimeTypes() mtypes.append(py3k.unicode_('application/my-form')) return mtypes