diff options
author | Marcelo Lira <marcelo.lira@openbossa.org> | 2011-08-18 13:12:09 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-08 16:17:12 -0300 |
commit | b7169ca7fe92c5874076ff47f9b4ec7954acc480 (patch) | |
tree | 3ff52c75c31e11583fb24a57423638410a1a14ea /tests/samplebinding | |
parent | 4f782f5d0f97633261690a19de7dfa62eeec2741 (diff) |
Added a test case for a bit-field structure member.
Also moved a couple of tests from samplebindings to otherbindings.
Diffstat (limited to 'tests/samplebinding')
-rw-r--r-- | tests/samplebinding/class_fields_test.py | 19 | ||||
-rw-r--r-- | tests/samplebinding/module_reload_test.py | 29 | ||||
-rw-r--r-- | tests/samplebinding/test_module_template.py | 12 | ||||
-rw-r--r-- | tests/samplebinding/typediscovery_test.py | 60 |
4 files changed, 19 insertions, 101 deletions
diff --git a/tests/samplebinding/class_fields_test.py b/tests/samplebinding/class_fields_test.py index eab138f4a..bee4cca87 100644 --- a/tests/samplebinding/class_fields_test.py +++ b/tests/samplebinding/class_fields_test.py @@ -140,5 +140,24 @@ class TestAccessingCppFields(unittest.TestCase): def testStaticField(self): self.assertEqual(Derived.staticPrimitiveField, 0) + def testAccessingUnsignedIntBitField(self): + d = Derived() + + # attribution + old_value = d.bitField + new_value = 1 + d.bitField= new_value + self.assertEqual(d.bitField, new_value) + self.assertNotEqual(d.bitField, old_value) + + # attribution with a convertible type + value = 1.2 + d.bitField = value + self.assertEqual(d.bitField, int(value)) + + # attribution with invalid type + self.assertRaises(TypeError, lambda : setattr(d, 'bitField', None)) + + if __name__ == '__main__': unittest.main() diff --git a/tests/samplebinding/module_reload_test.py b/tests/samplebinding/module_reload_test.py deleted file mode 100644 index 48d6d9572..000000000 --- a/tests/samplebinding/module_reload_test.py +++ /dev/null @@ -1,29 +0,0 @@ -import os -import sys -import shutil -import unittest - -orig_path = os.path.join(os.path.dirname(__file__)) -workdir = os.getcwd() -src = os.path.join(orig_path, 'test_module_template.py') -dst = os.path.join(workdir, 'test_module.py') -shutil.copyfile(src, dst) -sys.path.append(workdir) - -class TestModuleReloading(unittest.TestCase): - - def testModuleReloading(self): - '''Test module reloading with on-the-fly modifications.''' - - import test_module - - for i in range(3): - oldObject = test_module.obj - self.assertTrue(oldObject is test_module.obj) - reload(test_module) - self.assertFalse(oldObject is test_module.obj) - -if __name__ == "__main__": - unittest.main() - - diff --git a/tests/samplebinding/test_module_template.py b/tests/samplebinding/test_module_template.py deleted file mode 100644 index b6cfb8389..000000000 --- a/tests/samplebinding/test_module_template.py +++ /dev/null @@ -1,12 +0,0 @@ -from other import * -from sample import * - - -class MyObjectType(ObjectType): - pass - -class MyOtherObjectType(OtherObjectType): - value = 10 - - -obj = MyObjectType() diff --git a/tests/samplebinding/typediscovery_test.py b/tests/samplebinding/typediscovery_test.py deleted file mode 100644 index f7d5433ce..000000000 --- a/tests/samplebinding/typediscovery_test.py +++ /dev/null @@ -1,60 +0,0 @@ -#!/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 type discovery''' - -import unittest - -from sample import * -from other import * - -class TypeDiscoveryTest(unittest.TestCase): - - def testPureVirtualsOfImpossibleTypeDiscovery(self): - a = Derived.triggerImpossibleTypeDiscovery() - self.assertEqual(type(a), Abstract) - # call some pure virtual method - a.pureVirtual() - - def testAnotherImpossibleTypeDiscovery(self): - a = Derived.triggerAnotherImpossibleTypeDiscovery() - self.assertEqual(type(a), Derived) - - def testMultipleInheritance(self): - obj = OtherMultipleDerived.createObject("Base1"); - self.assertEqual(type(obj), Base1) - obj = OtherMultipleDerived.createObject("MDerived1"); - self.assertEqual(type(obj), MDerived1) - obj = OtherMultipleDerived.createObject("SonOfMDerived1"); - self.assertEqual(type(obj), SonOfMDerived1) - obj = OtherMultipleDerived.createObject("MDerived3"); - self.assertEqual(type(obj), MDerived3) - obj = OtherMultipleDerived.createObject("OtherMultipleDerived"); - self.assertEqual(type(obj), OtherMultipleDerived) - -if __name__ == '__main__': - unittest.main() - |