diff options
author | Marcelo Lira <marcelo.lira@openbossa.org> | 2009-10-23 16:12:38 -0300 |
---|---|---|
committer | Marcelo Lira <marcelo.lira@openbossa.org> | 2009-10-23 16:12:38 -0300 |
commit | 76892dffe7e79d45f9300ac496baec5063aa72fe (patch) | |
tree | cb5e04efdeecf2528201633190c02d711b610830 /tests | |
parent | dc6dbdc19c797628040a3ffe02c2189823620a84 (diff) |
added test for definition of __str__ method on type system
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/samplebinding/pystr_test.py | 44 | ||||
-rw-r--r-- | tests/samplebinding/typesystem_sample.xml | 8 |
2 files changed, 51 insertions, 1 deletions
diff --git a/tests/samplebinding/pystr_test.py b/tests/samplebinding/pystr_test.py new file mode 100755 index 000000000..a67e45f3d --- /dev/null +++ b/tests/samplebinding/pystr_test.py @@ -0,0 +1,44 @@ +#!/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 + +'''Test cases for definition of __str__ method.''' + +import sys +import unittest + +from sample import Point + +class PyStrTest(unittest.TestCase): + '''Test case for definition of __str__ method.''' + + def testPyStr(self): + '''Test case for defined __str__ method.''' + pt = Point(5, 2) + self.assertEqual(str(pt), 'Point(5, 2)') + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/samplebinding/typesystem_sample.xml b/tests/samplebinding/typesystem_sample.xml index 6055f9c48..363abb560 100644 --- a/tests/samplebinding/typesystem_sample.xml +++ b/tests/samplebinding/typesystem_sample.xml @@ -212,7 +212,13 @@ <value-type name="ImplicitConv"/> - <value-type name="Point"/> + <value-type name="Point"> + <add-function signature="__str__()" return-type="PyObject*"> + <inject-code class="target" position="beginning"> + %0 = PyString_FromFormat("Point(%d, %d)", (int) %CPPSELF.x(), (int) %CPPSELF.y()); + </inject-code> + </add-function> + </value-type> <value-type name="Size"/> <value-type name="MapUser"/> <value-type name="PairUser"/> |