aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/tests/samplebinding/modifications_test.py
diff options
context:
space:
mode:
Diffstat (limited to 'sources/shiboken6/tests/samplebinding/modifications_test.py')
-rw-r--r--sources/shiboken6/tests/samplebinding/modifications_test.py73
1 files changed, 24 insertions, 49 deletions
diff --git a/sources/shiboken6/tests/samplebinding/modifications_test.py b/sources/shiboken6/tests/samplebinding/modifications_test.py
index 3429ccd0f..dced14396 100644
--- a/sources/shiboken6/tests/samplebinding/modifications_test.py
+++ b/sources/shiboken6/tests/samplebinding/modifications_test.py
@@ -1,36 +1,10 @@
#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-#
-#############################################################################
-##
-## Copyright (C) 2016 The Qt Company Ltd.
-## Contact: https://www.qt.io/licensing/
-##
-## This file is part of the test suite of Qt for Python.
-##
-## $QT_BEGIN_LICENSE:GPL-EXCEPT$
-## Commercial License Usage
-## Licensees holding valid commercial Qt licenses may use this file in
-## accordance with the commercial license agreement provided with the
-## Software or, alternatively, in accordance with the terms contained in
-## a written agreement between you and The Qt Company. For licensing terms
-## and conditions see https://www.qt.io/terms-conditions. For further
-## information use the contact form at https://www.qt.io/contact-us.
-##
-## GNU General Public License Usage
-## Alternatively, this file may be used under the terms of the GNU
-## General Public License version 3 as published by the Free Software
-## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-## included in the packaging of this file. Please review the following
-## information to ensure the GNU General Public License requirements will
-## be met: https://www.gnu.org/licenses/gpl-3.0.html.
-##
-## $QT_END_LICENSE$
-##
-#############################################################################
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
'''Test cases for method modifications performed as described on type system. '''
+import gc
import os
import sys
import unittest
@@ -42,6 +16,7 @@ init_paths()
from sample import Modifications, Point, ByteArray
+
class ExtModifications(Modifications):
def __init__(self):
Modifications.__init__(self)
@@ -64,25 +39,18 @@ class ModificationsTest(unittest.TestCase):
def tearDown(self):
del self.mods
-
- def testClassMembersAvailability(self):
- '''Test if Modified class really have the expected members.'''
- expected_members = set(['OverloadedModFunc', 'OverloadedNone',
- 'Overloaded_ibiP', 'Overloaded_ibib',
- 'Overloaded_ibid', 'Overloaded_ibii',
- 'calculateArea', 'doublePlus', 'increment',
- 'multiplyPointCoordsPlusValue', 'name',
- 'pointToPair', 'overloaded', 'power',
- 'timesTen'])
- self.assertTrue(expected_members.issubset(dir(Modifications)))
+ # PYSIDE-535: Need to collect garbage in PyPy to trigger deletion
+ gc.collect()
def testRenamedMethodAvailability(self):
- '''Test if Modification class really have renamed the 'className' virtual method to 'name'.'''
+ '''Test if Modification class really have renamed the 'className'
+ virtual method to 'name'.'''
self.assertTrue('className' not in dir(Modifications))
self.assertTrue('name' in dir(Modifications))
def testReimplementationOfRenamedVirtualMethod(self):
- '''Test if class inheriting from Modification class have the reimplementation of renamed virtual method called.'''
+ '''Test if class inheriting from Modification class have the reimplementation
+ of renamed virtual method called.'''
em = ExtModifications()
self.assertEqual(self.mods.name(), 'Modifications')
self.assertEqual(em.name(), 'ExtModifications')
@@ -103,12 +71,14 @@ class ModificationsTest(unittest.TestCase):
self.assertEqual(self.mods.doublePlus(7), 14)
def testDefaultValueRemoval(self):
- '''Test if default value was removed from first argument of Modifications::increment(int).'''
+ '''Test if default value was removed from first argument of
+ Modifications::increment(int).'''
self.assertRaises(TypeError, self.mods.increment)
self.assertEqual(self.mods.increment(7), 8)
def testDefaultValueReplacement(self):
- '''Test if default values for both arguments of Modifications::power(int, int) were modified.'''
+ '''Test if default values for both arguments of Modifications::power(int, int)
+ were modified.'''
# original default values: int power(int base = 1, int exponent = 0);
self.assertNotEqual(self.mods.power(4), 1)
# modified default values: int power(int base = 2, int exponent = 1);
@@ -117,12 +87,14 @@ class ModificationsTest(unittest.TestCase):
self.assertEqual(self.mods.power(5, 3), 5**3)
def testSetNewDefaultValue(self):
- '''Test if default value was correctly set to 10 for first argument of Modifications::timesTen(int).'''
+ '''Test if default value was correctly set to 10 for first argument of
+ Modifications::timesTen(int).'''
self.assertEqual(self.mods.timesTen(7), 70)
self.assertEqual(self.mods.timesTen(), 100)
def testArgumentRemovalAndReturnTypeModificationWithTypesystemTemplates1(self):
- '''Test modifications to method signature and return value using type system templates (case 1).'''
+ '''Test modifications to method signature and return value using type
+ system templates (case 1).'''
result, ok = self.mods.pointToPair(Point(2, 5))
self.assertEqual(type(ok), bool)
self.assertEqual(type(result), tuple)
@@ -133,7 +105,8 @@ class ModificationsTest(unittest.TestCase):
self.assertEqual(result[1], 5.0)
def testArgumentRemovalAndReturnTypeModificationWithTypesystemTemplates2(self):
- '''Test modifications to method signature and return value using type system templates (case 2).'''
+ '''Test modifications to method signature and return value using
+ type system templates (case 2).'''
result, ok = self.mods.multiplyPointCoordsPlusValue(Point(2, 5), 4.1)
self.assertEqual(type(ok), bool)
self.assertEqual(type(result), float)
@@ -147,9 +120,11 @@ class ModificationsTest(unittest.TestCase):
self.assertEqual(self.mods.overloaded(1, True, 2), Modifications.Overloaded_ibii)
# the others weren't modified
self.assertEqual(self.mods.overloaded(1, True, 2, False), Modifications.Overloaded_ibib)
- self.assertEqual(self.mods.overloaded(1, False, 2, Point(3, 4)), Modifications.Overloaded_ibiP)
+ self.assertEqual(self.mods.overloaded(1, False, 2, Point(3, 4)),
+ Modifications.Overloaded_ibiP)
self.assertRaises(TypeError, self.mods.overloaded, 1, True, Point(2, 3), Point(4, 5))
- self.assertEqual(self.mods.over(1, True, Point(2, 3), Point(4, 5)), Modifications.Overloaded_ibPP)
+ self.assertEqual(self.mods.over(1, True, Point(2, 3), Point(4, 5)),
+ Modifications.Overloaded_ibPP)
def testPointArrayModification(self):
points = (Point(1, 1), Point(2, 2))