aboutsummaryrefslogtreecommitdiffstats
path: root/tests/samplebinding/ownership_argument_invalidation_test.py
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2009-11-26 17:33:26 -0300
committerMarcelo Lira <marcelo.lira@openbossa.org>2009-11-26 18:00:32 -0300
commitf694fbbff8999bde36fcd161c3b3f369c7f3e6a1 (patch)
treeeca6ded94a1b7a589a6956fb4fbc0f58794e8a48 /tests/samplebinding/ownership_argument_invalidation_test.py
parent609f863f04e9f29e562f7b091bd4f1cb603b23dd (diff)
Added tests for the validity of Python wrappers used as method arguments.
Reviewed by Luciano Wolf <luciano.wolf@openbossa.org>
Diffstat (limited to 'tests/samplebinding/ownership_argument_invalidation_test.py')
-rwxr-xr-xtests/samplebinding/ownership_argument_invalidation_test.py57
1 files changed, 57 insertions, 0 deletions
diff --git a/tests/samplebinding/ownership_argument_invalidation_test.py b/tests/samplebinding/ownership_argument_invalidation_test.py
new file mode 100755
index 000000000..6562a287a
--- /dev/null
+++ b/tests/samplebinding/ownership_argument_invalidation_test.py
@@ -0,0 +1,57 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# This file is part of the Shiboken Python Bindings Generator project.
+#
+# Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+#
+# Contact: PySide team <contact@pyside.org>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public License
+# version 2.1 as published by the Free Software Foundation. Please
+# review the following information to ensure the GNU Lesser General
+# Public License version 2.1 requirements will be met:
+# http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+# #
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA
+
+'''Wrapper validity tests for arguments.'''
+
+import sys
+import unittest
+
+from sample import Polygon, Point
+
+class WrapperValidityOfArgumentsTest(unittest.TestCase):
+ '''Wrapper validity tests for arguments.'''
+
+ def testInvalidArgumentToMethod(self):
+ '''Call to method using invalidated Python wrapper as argument should raise RuntimeError.'''
+ poly = Polygon()
+ Polygon.stealOwnershipFromPython(poly)
+ self.assertRaises(RuntimeError, lambda : Polygon.doublePolygonScale(poly))
+
+ def testInvalidArgumentToConstructor(self):
+ '''Call to constructor using invalidated Python wrapper as argument should raise RuntimeError.'''
+ pt = Point(1, 2)
+ Polygon.stealOwnershipFromPython(pt)
+ self.assertRaises(RuntimeError, lambda : Polygon(pt))
+
+ def testInvalidArgumentWithImplicitConversion(self):
+ '''Call to method using invalidated Python wrapper to be implicitly converted should raise RuntimeError.'''
+ pt = Point(1, 2)
+ Polygon.stealOwnershipFromPython(pt)
+ self.assertRaises(RuntimeError, lambda : Polygon.doublePolygonScale(pt))
+
+if __name__ == '__main__':
+ unittest.main()
+