Updated QtWebKit modue to works with python 2.x and 3.x
This commit is contained in:
parent
e90255bf7e
commit
de291d1d0f
2 changed files with 12 additions and 14 deletions
|
|
@ -1,40 +1,40 @@
|
||||||
from PySide.QtCore import QObject, Slot, QTimer
|
from PySide.QtCore import QObject, Slot, QTimer
|
||||||
from PySide.QtWebKit import QWebView, QWebPage
|
from PySide.QtWebKit import QWebView
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
from helper import UsesQApplication
|
from helper import UsesQApplication
|
||||||
|
|
||||||
class JSFuncs(QObject):
|
class JSFuncs(QObject):
|
||||||
functionID = -1
|
functionID = -1
|
||||||
@Slot(unicode,result=unicode)
|
@Slot(str,result=str)
|
||||||
def slot_str_str(self, x):
|
def slot_str_str(self, x):
|
||||||
JSFuncs.functionID = 0
|
JSFuncs.functionID = 0
|
||||||
return x.upper()
|
return x.upper()
|
||||||
|
|
||||||
@Slot(unicode,result='QVariant')
|
@Slot(str,result='QVariant')
|
||||||
def slot_str_list(self, x):
|
def slot_str_list(self, x):
|
||||||
JSFuncs.functionID = 1
|
JSFuncs.functionID = 1
|
||||||
return [x, x]
|
return [x, x]
|
||||||
|
|
||||||
@Slot('QStringList',result=unicode)
|
@Slot('QStringList',result=str)
|
||||||
def slot_strlist_str(self, x):
|
def slot_strlist_str(self, x):
|
||||||
JSFuncs.functionID = 2
|
JSFuncs.functionID = 2
|
||||||
return x[-1]
|
return x[-1]
|
||||||
|
|
||||||
@Slot('QVariant',result=unicode)
|
@Slot('QVariant',result=str)
|
||||||
def slot_variant_str(self, x):
|
def slot_variant_str(self, x):
|
||||||
JSFuncs.functionID = 3
|
JSFuncs.functionID = 3
|
||||||
return unicode(x)
|
return str(x)
|
||||||
|
|
||||||
@Slot('QVariantList',result=unicode)
|
@Slot('QVariantList',result=str)
|
||||||
def slot_variantlist_str(self, x):
|
def slot_variantlist_str(self, x):
|
||||||
JSFuncs.functionID = 4
|
JSFuncs.functionID = 4
|
||||||
return unicode(x[-1])
|
return str(x[-1])
|
||||||
|
|
||||||
@Slot('QVariantMap',result=unicode)
|
@Slot('QVariantMap',result=str)
|
||||||
def slot_variantmap_str(self, x):
|
def slot_variantmap_str(self, x):
|
||||||
JSFuncs.functionID = 5
|
JSFuncs.functionID = 5
|
||||||
return unicode(x["foo"])
|
return str(x["foo"])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,11 @@
|
||||||
'''Test cases for QWebView'''
|
'''Test cases for QWebView'''
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
import py3kcompat as py3k
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from PySide.QtCore import QObject, SIGNAL, QUrl
|
from PySide.QtCore import QObject, SIGNAL, QUrl
|
||||||
from PySide.QtWebKit import *
|
from PySide.QtWebKit import QWebPage, QWebView
|
||||||
from PySide.QtNetwork import QNetworkRequest
|
from PySide.QtNetwork import QNetworkRequest
|
||||||
|
|
||||||
from helper import adjust_filename, TimedQApplication
|
from helper import adjust_filename, TimedQApplication
|
||||||
|
|
@ -62,8 +63,5 @@ class TestLoadFinished(TimedQApplication):
|
||||||
if ok:
|
if ok:
|
||||||
self.called = True
|
self.called = True
|
||||||
|
|
||||||
def testNamedArgumentTypeChecking(self):
|
|
||||||
self.assertRaises(TypeError, self.view.load, QNetworkRequest(), body=unicode('foo'))
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue