summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2011-07-28 16:37:12 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2011-07-29 10:48:02 -0300
commit20af27cac5c59ff891cd01c4902a3575f7f92241 (patch)
treed7f8c77079e0bb5cfd408e908daca899a29db44c /tests
parentd38ba8cbb825a70402775745e3cff9c8fa432dae (diff)
downloadpyside-20af27cac5c59ff891cd01c4902a3575f7f92241.tar.gz
pyside-20af27cac5c59ff891cd01c4902a3575f7f92241.tar.xz
pyside-20af27cac5c59ff891cd01c4902a3575f7f92241.zip
Fix bug 923 - "Make QScriptValue (or QScriptValueIterator) implement the Python iterator protocol"
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org> Luciano Wolf <luciano.wolf@openbossa.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/QtScript/qscriptvalue_test.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/tests/QtScript/qscriptvalue_test.py b/tests/QtScript/qscriptvalue_test.py
index d029bf9..e5b6a63 100644
--- a/tests/QtScript/qscriptvalue_test.py
+++ b/tests/QtScript/qscriptvalue_test.py
@@ -1,6 +1,6 @@
import unittest
import PySide
-from PySide.QtScript import QScriptEngine, QScriptValue
+from PySide.QtScript import *
from helper import UsesQApplication
@@ -19,6 +19,20 @@ class TestQScriptValue (UsesQApplication):
value = QScriptValue("somePerson = { firstName: 'John', lastName: 'Doe' }")
value2 = eval(repr(value))
self.assertEqual(value.toString(), value2.toString())
+ self.assertEqual(value.toVariant(), value2.toVariant())
+
+ def testIteratorProtocol(self):
+ engine = QScriptEngine()
+ value = engine.evaluate('x = {"a": 1, "b":2}')
+ d = {}
+ for k, v in QScriptValueIterator(value):
+ d[k] = v
+ self.assertEqual(d, {'a': 1, 'b': 2})
+
+ d = {}
+ for k, v in value:
+ d[k] = v
+ self.assertEqual(d, {'a': 1, 'b': 2})
if __name__ == '__main__':
unittest.main()