aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/tests/samplebinding/injectcode_test.py
diff options
context:
space:
mode:
Diffstat (limited to 'sources/shiboken6/tests/samplebinding/injectcode_test.py')
-rw-r--r--sources/shiboken6/tests/samplebinding/injectcode_test.py50
1 files changed, 15 insertions, 35 deletions
diff --git a/sources/shiboken6/tests/samplebinding/injectcode_test.py b/sources/shiboken6/tests/samplebinding/injectcode_test.py
index a6fb7a5ef..f673a7807 100644
--- a/sources/shiboken6/tests/samplebinding/injectcode_test.py
+++ b/sources/shiboken6/tests/samplebinding/injectcode_test.py
@@ -1,33 +1,6 @@
#!/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 std::list container conversions'''
@@ -41,6 +14,7 @@ from shiboken_paths import init_paths
init_paths()
from sample import InjectCode
+
class MyInjectCode(InjectCode):
def __init__(self):
InjectCode.__init__(self)
@@ -49,8 +23,11 @@ class MyInjectCode(InjectCode):
def arrayMethod(self, values):
return self.multiplier * sum(values)
+
class InjectCodeTest(unittest.TestCase):
+ @unittest.skipIf(hasattr(sys, "pypy_version_info"),
+ "PyPy type objects cannot be modified (yet) after creation")
def testTypeNativeBeginning_TypeTargetBeginning(self):
ic = InjectCode()
self.assertEqual(str(ic), "Hi! I'm the inject code dummy class.")
@@ -96,22 +73,24 @@ class InjectCodeTest(unittest.TestCase):
self.assertEqual(result, sum(values))
def testCallReimplementedVirtualMethodWithArgumentRemovalAndArgumentTypeModification(self):
- '''Calls a reimplemented virtual method that had its first argument removed and the second modified.'''
+ '''Calls a reimplemented virtual method that had its first argument removed
+ and the second modified.'''
ic = MyInjectCode()
values = (1, 2, 3, 4, 5)
result = ic.callArrayMethod(values)
self.assertEqual(result, ic.multiplier * sum(values))
def testUsageOfTypeSystemCheckVariableOnPrimitiveType(self):
- '''When the sequence item is convertible to an integer -1 is returned, or -2 if its not convertible.'''
+ '''When the sequence item is convertible to an integer -1 is returned,
+ or -2 if its not convertible.'''
ic = InjectCode()
values = (1, 2, 3, 4, '5', 6.7)
result = ic.arrayMethod(values)
- fixedValues = [v for v in values if isinstance(v, int)]\
- + [-1 for v in values if isinstance(v, float)]\
- + [-2 for v in values if not isinstance(v, int) and not isinstance(v, float)]
- self.assertEqual(result, sum(fixedValues))
+ ints = [v for v in values if isinstance(v, int)]
+ floats = [-1 for v in values if isinstance(v, float)]
+ other = [-2 for v in values if not isinstance(v, int) and not isinstance(v, float)]
+ self.assertEqual(result, sum(ints + floats + other))
class IntArrayTest(unittest.TestCase):
@@ -135,5 +114,6 @@ class IntArrayTest(unittest.TestCase):
ic = InjectCode()
self.assertEqual(sum([1, 2]) + len([1, 2]), ic.sumArrayAndLength(args))
+
if __name__ == '__main__':
unittest.main()