1#!/usr/bin/env python 2# -*- coding: utf-8 -*- 3# 4############################################################################# 5## 6## Copyright (C) 2016 The Qt Company Ltd. 7## Contact: https://www.qt.io/licensing/ 8## 9## This file is part of the test suite of Qt for Python. 10## 11## $QT_BEGIN_LICENSE:GPL-EXCEPT$ 12## Commercial License Usage 13## Licensees holding valid commercial Qt licenses may use this file in 14## accordance with the commercial license agreement provided with the 15## Software or, alternatively, in accordance with the terms contained in 16## a written agreement between you and The Qt Company. For licensing terms 17## and conditions see https://www.qt.io/terms-conditions. For further 18## information use the contact form at https://www.qt.io/contact-us. 19## 20## GNU General Public License Usage 21## Alternatively, this file may be used under the terms of the GNU 22## General Public License version 3 as published by the Free Software 23## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT 24## included in the packaging of this file. Please review the following 25## information to ensure the GNU General Public License requirements will 26## be met: https://www.gnu.org/licenses/gpl-3.0.html. 27## 28## $QT_END_LICENSE$ 29## 30############################################################################# 31 32'''Test cases for multiple inheritance''' 33 34import os 35import sys 36import unittest 37 38sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) 39from shiboken_paths import init_paths 40init_paths() 41 42from sample import * 43 44class SimpleUseCase(ObjectType, Str): 45 def __init__(self, name): 46 ObjectType.__init__(self) 47 Str.__init__(self, name) 48 49class SimpleUseCaseReverse(Str, ObjectType): 50 def __init__(self, name): 51 ObjectType.__init__(self) 52 Str.__init__(self, name) 53 54class SimpleUseCase2(SimpleUseCase): 55 def __init__(self, name): 56 SimpleUseCase.__init__(self, name) 57 58class ComplexUseCase(SimpleUseCase2, Point): 59 def __init__(self, name): 60 SimpleUseCase2.__init__(self, name) 61 Point.__init__(self) 62 63class ComplexUseCaseReverse(Point, SimpleUseCase2): 64 def __init__(self, name): 65 SimpleUseCase2.__init__(self, name) 66 Point.__init__(self) 67 68class MultipleCppDerivedTest(unittest.TestCase): 69 def testInstanciation(self): 70 s = SimpleUseCase("Hi") 71 self.assertEqual(s, "Hi") 72 s.setObjectName(s) 73 self.assertEqual(s.objectName(), "Hi") 74 75 def testInstanciation2(self): 76 s = SimpleUseCase2("Hi") 77 self.assertEqual(s, "Hi") 78 s.setObjectName(s) 79 self.assertEqual(s.objectName(), "Hi") 80 81 def testComplexInstanciation(self): 82 c = ComplexUseCase("Hi") 83 self.assertEqual(c, "Hi") 84 c.setObjectName(c) 85 self.assertEqual(c.objectName(), "Hi") 86 c.setX(2); 87 self.assertEqual(c.x(), 2) 88 89class MultipleCppDerivedReverseTest(unittest.TestCase): 90 def testInstanciation(self): 91 s = SimpleUseCaseReverse("Hi") 92 self.assertEqual(s, "Hi") 93 s.setObjectName(s) 94 self.assertEqual(s.objectName(), "Hi") 95 96 def testInstanciation2(self): 97 s = SimpleUseCase2("Hi") 98 self.assertEqual(s, "Hi") 99 s.setObjectName(s) 100 self.assertEqual(s.objectName(), "Hi") 101 102 def testComplexInstanciation(self): 103 c = ComplexUseCaseReverse("Hi") 104 c.setObjectName(c) 105 self.assertEqual(c.objectName(), "Hi") 106 c.setX(2); 107 self.assertEqual(c, Point(2, 0)) 108 109if __name__ == '__main__': 110 unittest.main() 111