diff options
Diffstat (limited to 'sources/shiboken2/tests/otherbinding')
17 files changed, 0 insertions, 990 deletions
diff --git a/sources/shiboken2/tests/otherbinding/CMakeLists.txt b/sources/shiboken2/tests/otherbinding/CMakeLists.txt deleted file mode 100644 index 05a282838..000000000 --- a/sources/shiboken2/tests/otherbinding/CMakeLists.txt +++ /dev/null @@ -1,46 +0,0 @@ -project(other) - -set(other_TYPESYSTEM -${CMAKE_CURRENT_SOURCE_DIR}/typesystem_other.xml -) - -set(other_SRC -${CMAKE_CURRENT_BINARY_DIR}/other/extendsnoimplicitconversion_wrapper.cpp -${CMAKE_CURRENT_BINARY_DIR}/other/number_wrapper.cpp -${CMAKE_CURRENT_BINARY_DIR}/other/otherderived_wrapper.cpp -${CMAKE_CURRENT_BINARY_DIR}/other/othermultiplederived_wrapper.cpp -${CMAKE_CURRENT_BINARY_DIR}/other/otherobjecttype_wrapper.cpp -${CMAKE_CURRENT_BINARY_DIR}/other/sharedptr_str_wrapper.cpp -${CMAKE_CURRENT_BINARY_DIR}/other/smartptrtester_wrapper.cpp -${CMAKE_CURRENT_BINARY_DIR}/other/other_module_wrapper.cpp -) - - -configure_file("${CMAKE_CURRENT_SOURCE_DIR}/other-binding.txt.in" - "${CMAKE_CURRENT_BINARY_DIR}/other-binding.txt" @ONLY) - -add_custom_command( -OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/mjb_rejected_classes.log" -BYPRODUCTS ${other_SRC} -COMMAND shiboken2 --project-file=${CMAKE_CURRENT_BINARY_DIR}/other-binding.txt ${GENERATOR_EXTRA_FLAGS} -DEPENDS ${other_TYPESYSTEM} ${CMAKE_CURRENT_SOURCE_DIR}/global.h shiboken2 -WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} -COMMENT "Running generator for 'other' test binding..." -) - -add_library(other MODULE ${other_SRC}) -target_include_directories(other PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - ${sample_BINARY_DIR}/sample - ${smart_BINARY_DIR}/smart) -target_link_libraries(other PUBLIC libother libsample libsmart libshiboken) -set_property(TARGET other PROPERTY PREFIX "") -set_property(TARGET other PROPERTY OUTPUT_NAME "other${PYTHON_EXTENSION_SUFFIX}") - -if(WIN32) - set_property(TARGET other PROPERTY SUFFIX ".pyd") -endif() - - -add_dependencies(other sample smart) -create_generator_target(other) - diff --git a/sources/shiboken2/tests/otherbinding/collector_external_operator_test.py b/sources/shiboken2/tests/otherbinding/collector_external_operator_test.py deleted file mode 100644 index 6014b8a59..000000000 --- a/sources/shiboken2/tests/otherbinding/collector_external_operator_test.py +++ /dev/null @@ -1,64 +0,0 @@ -#!/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$ -## -############################################################################# - -'''Test cases for Collector shift operators defined in other modules.''' - -import os -import sys -import unittest - -sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) -from shiboken_paths import init_paths -init_paths() - -from sample import Collector, ObjectType -from other import OtherObjectType - -class CollectorOtherObjectType(unittest.TestCase): - '''Test cases for Collector << OtherObjectType''' - - def testLShiftWithExpectedType(self): - '''Collector << ObjectType # libsample << operator''' - collector = Collector() - obj = ObjectType() - collector << obj - self.assertEqual(collector.items()[0], obj.identifier()) - - def testOtherReversal(self): - '''Collector << OtherObjectType # libother << operator''' - collector = Collector() - obj = OtherObjectType() - collector << obj - self.assertEqual(collector.items()[0], obj.identifier() * 2) - -if __name__ == '__main__': - unittest.main() - diff --git a/sources/shiboken2/tests/otherbinding/conversion_operator_for_class_without_implicit_conversions_test.py b/sources/shiboken2/tests/otherbinding/conversion_operator_for_class_without_implicit_conversions_test.py deleted file mode 100644 index 1e992ebc8..000000000 --- a/sources/shiboken2/tests/otherbinding/conversion_operator_for_class_without_implicit_conversions_test.py +++ /dev/null @@ -1,79 +0,0 @@ -#!/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$ -## -############################################################################# - -'''Tests calling NoImplicitConversion using a ExtendsNoImplicitConversion parameter, - being that the latter defines a new conversion operator for the former, and this one - has no implicit conversions.''' - -import os -import sys -import unittest - -sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) -from shiboken_paths import init_paths -init_paths() - -from sample import NoImplicitConversion -from other import ExtendsNoImplicitConversion - -class ConversionOperatorForClassWithoutImplicitConversionsTest(unittest.TestCase): - '''Tests calling NoImplicitConversion constructor using a ExtendsNoImplicitConversion parameter.''' - - def testNoImplicitConversion(self): - '''Basic test to see if the NoImplicitConversion is Ok.''' - obj = NoImplicitConversion(123) - # NoImplicitConversion.receivesNoImplicitConversionByValue(NoImplicitConversion) - self.assertEqual(obj.objId(), NoImplicitConversion.receivesNoImplicitConversionByValue(obj)) - # NoImplicitConversion.receivesNoImplicitConversionByPointer(NoImplicitConversion*) - self.assertEqual(obj.objId(), NoImplicitConversion.receivesNoImplicitConversionByPointer(obj)) - # NoImplicitConversion.receivesNoImplicitConversionByReference(NoImplicitConversion&) - self.assertEqual(obj.objId(), NoImplicitConversion.receivesNoImplicitConversionByReference(obj)) - - def testPassingExtendsNoImplicitConversionAsNoImplicitConversionByValue(self): - '''Gives an ExtendsNoImplicitConversion object to a function expecting a NoImplicitConversion, passing by value.''' - obj = ExtendsNoImplicitConversion(123) - self.assertEqual(obj.objId(), NoImplicitConversion.receivesNoImplicitConversionByValue(obj)) - - def testPassingExtendsNoImplicitConversionAsNoImplicitConversionByReference(self): - '''Gives an ExtendsNoImplicitConversion object to a function expecting a NoImplicitConversion, passing by reference.''' - obj = ExtendsNoImplicitConversion(123) - self.assertEqual(obj.objId(), NoImplicitConversion.receivesNoImplicitConversionByReference(obj)) - - def testPassingExtendsNoImplicitConversionAsNoImplicitConversionByPointer(self): - '''Gives an ExtendsNoImplicitConversion object to a function expecting a NoImplicitConversion, passing by pointer. - This should not be accepted, since pointers should not be converted.''' - obj = ExtendsNoImplicitConversion(123) - self.assertRaises(TypeError, NoImplicitConversion.receivesNoImplicitConversionByPointer, obj) - - -if __name__ == '__main__': - unittest.main() - diff --git a/sources/shiboken2/tests/otherbinding/extended_multiply_operator_test.py b/sources/shiboken2/tests/otherbinding/extended_multiply_operator_test.py deleted file mode 100644 index 5ad4763b7..000000000 --- a/sources/shiboken2/tests/otherbinding/extended_multiply_operator_test.py +++ /dev/null @@ -1,70 +0,0 @@ -#!/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$ -## -############################################################################# - -'''Test cases for libsample's Point multiply operator defined in libother module.''' - -import os -import sys -import unittest - -sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) -from shiboken_paths import init_paths -init_paths() - -from sample import Point -from other import Number - -class PointOperationsWithNumber(unittest.TestCase): - '''Test cases for libsample's Point multiply operator defined in libother module.''' - - def testPointTimesInt(self): - '''sample.Point * int''' - pt1 = Point(2, 7) - num = 3 - pt2 = Point(pt1.x() * num, pt1.y() * num) - self.assertEqual(pt1 * num, pt2) - - def testIntTimesPoint(self): - '''int * sample.Point''' - pt1 = Point(2, 7) - num = 3 - pt2 = Point(pt1.x() * num, pt1.y() * num) - self.assertEqual(num * pt1, pt2) - - def testPointTimesNumber(self): - '''sample.Point * other.Number''' - pt = Point(2, 7) - num = Number(11) - self.assertEqual(pt * num.value(), pt * 11) - -if __name__ == '__main__': - unittest.main() - diff --git a/sources/shiboken2/tests/otherbinding/global.h b/sources/shiboken2/tests/otherbinding/global.h deleted file mode 100644 index 763566ae0..000000000 --- a/sources/shiboken2/tests/otherbinding/global.h +++ /dev/null @@ -1,36 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#include "../samplebinding/global.h" -#include "extendsnoimplicitconversion.h" -#include "number.h" -#include "otherderived.h" -#include "otherobjecttype.h" -#include "othermultiplederived.h" -#include "smartptrtester.h" - diff --git a/sources/shiboken2/tests/otherbinding/module_reload_test.py b/sources/shiboken2/tests/otherbinding/module_reload_test.py deleted file mode 100644 index 368425cd0..000000000 --- a/sources/shiboken2/tests/otherbinding/module_reload_test.py +++ /dev/null @@ -1,65 +0,0 @@ -#!/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$ -## -############################################################################# - -import os -import shutil -import sys -import unittest - -sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) -from shiboken_paths import init_paths -init_paths() - -from py3kcompat import IS_PY3K - -if IS_PY3K: - from imp import reload - -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/sources/shiboken2/tests/otherbinding/new_ctor_operator_test.py b/sources/shiboken2/tests/otherbinding/new_ctor_operator_test.py deleted file mode 100644 index 84dfe9839..000000000 --- a/sources/shiboken2/tests/otherbinding/new_ctor_operator_test.py +++ /dev/null @@ -1,62 +0,0 @@ -#!/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$ -## -############################################################################# - -'''Tests calling Str constructor using a Number parameter, being that number defines a cast operator to Str.''' - -import os -import sys -import unittest - -sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) -from shiboken_paths import init_paths -init_paths() - -from sample import Str -from other import Number - -class NewCtorOperatorTest(unittest.TestCase): - '''Tests calling Str constructor using a Number parameter, being that number defines a cast operator to Str.''' - - def testNumber(self): - '''Basic test to see if the Number class is Ok.''' - value = 123 - num = Number(value) - self.assertEqual(num.value(), value) - - def testStrCtorWithNumberArgument(self): - '''Try to build a Str from 'sample' module with a Number argument from 'other' module.''' - value = 123 - num = Number(value) - string = Str(num) - -if __name__ == '__main__': - unittest.main() - diff --git a/sources/shiboken2/tests/otherbinding/objtypehashes_test.py b/sources/shiboken2/tests/otherbinding/objtypehashes_test.py deleted file mode 100644 index 92f93a090..000000000 --- a/sources/shiboken2/tests/otherbinding/objtypehashes_test.py +++ /dev/null @@ -1,59 +0,0 @@ -############################################################################# -## -## 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$ -## -############################################################################# - -import os -import sys -import unittest - -sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) -from shiboken_paths import init_paths -init_paths() -from sample import * -from other import * -import shiboken2 as shiboken - -class TestHashFuncs (unittest.TestCase): - - def testIt(self): - obj1 = HandleHolder() - obj2 = HandleHolder() - - hash1 = hash(obj1) - hash2 = hash(obj2) - self.assertNotEqual(hash1, hash2) - - # Now invalidate the object and test its hash. It shouldn't segfault. - shiboken.invalidate(obj1) - - hash1_2 = hash(obj1) - self.assertEqual(hash1_2, hash1) - - - -if __name__ == '__main__': - unittest.main() diff --git a/sources/shiboken2/tests/otherbinding/other-binding.txt.in b/sources/shiboken2/tests/otherbinding/other-binding.txt.in deleted file mode 100644 index dbe935a9f..000000000 --- a/sources/shiboken2/tests/otherbinding/other-binding.txt.in +++ /dev/null @@ -1,20 +0,0 @@ -[generator-project] - -generator-set = shiboken - -header-file = @CMAKE_CURRENT_SOURCE_DIR@/global.h -typesystem-file = @other_TYPESYSTEM@ - -output-directory = @CMAKE_CURRENT_BINARY_DIR@ - -include-path = @libother_SOURCE_DIR@ -include-path = @libsmart_SOURCE_DIR@ -include-path = @libsample_SOURCE_DIR@ -include-path = @libsample_SOURCE_DIR@/.. - -typesystem-path = @CMAKE_CURRENT_SOURCE_DIR@ -typesystem-path = @sample_SOURCE_DIR@ -typesystem-path = @smart_SOURCE_DIR@ - -enable-parent-ctor-heuristic - diff --git a/sources/shiboken2/tests/otherbinding/otherderived_test.py b/sources/shiboken2/tests/otherbinding/otherderived_test.py deleted file mode 100644 index d8dc9b686..000000000 --- a/sources/shiboken2/tests/otherbinding/otherderived_test.py +++ /dev/null @@ -1,125 +0,0 @@ -#!/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$ -## -############################################################################# - -'''Test cases for OtherDerived class''' - -import os -import sys -import unittest - -sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) -from shiboken_paths import init_paths -init_paths() - -from sample import Abstract, Derived -from other import OtherDerived, Number - -class Multiple(Derived, Number): - def __init__(self): - Derived.__init__(self, 42) - Number.__init__(self, 42) - - def testCall(self): - return True - -class OtherDeviant(OtherDerived): - def __init__(self): - OtherDerived.__init__(self) - self.pure_virtual_called = False - self.unpure_virtual_called = False - - def pureVirtual(self): - self.pure_virtual_called = True - - def unpureVirtual(self): - self.unpure_virtual_called = True - - def className(self): - return 'OtherDeviant' - -class MultipleTest(unittest.TestCase): - '''Test case for Multiple derived class''' - - def testConstructor(self): - o = Multiple() - self.assertTrue(isinstance(o, Multiple)) - self.assertTrue(isinstance(o, Number)) - self.assertTrue(isinstance(o, Derived)) - del o - - def testMethodCall(self): - o = Multiple() - self.assertTrue(o.id_(), 42) - self.assertTrue(o.value(), 42) - self.assertTrue(o.testCall()) - -class OtherDerivedTest(unittest.TestCase): - '''Test case for OtherDerived class''' - - def testParentClassMethodsAvailability(self): - '''Test if OtherDerived class really inherits its methods from parent.''' - inherited_methods = set(['callPureVirtual', 'callUnpureVirtual', - 'id_', 'pureVirtual', 'unpureVirtual']) - self.assertTrue(inherited_methods.issubset(dir(OtherDerived))) - - def testReimplementedPureVirtualMethodCall(self): - '''Test if a Python override of a implemented pure virtual method is correctly called from C++.''' - d = OtherDeviant() - d.callPureVirtual() - self.assertTrue(d.pure_virtual_called) - - def testReimplementedVirtualMethodCall(self): - '''Test if a Python override of a reimplemented virtual method is correctly called from C++.''' - d = OtherDeviant() - d.callUnpureVirtual() - self.assertTrue(d.unpure_virtual_called) - - def testVirtualMethodCallString(self): - '''Test virtual method call returning string.''' - d = OtherDerived() - self.assertEqual(d.className(), 'OtherDerived') - self.assertEqual(d.getClassName(), 'OtherDerived') - - def testReimplementedVirtualMethodCallReturningString(self): - '''Test if a Python override of a reimplemented virtual method is correctly called from C++.''' - d = OtherDeviant() - self.assertEqual(d.className(), 'OtherDeviant') - self.assertEqual(d.getClassName(), 'OtherDeviant') - - def testCallToMethodWithAbstractArgument(self): - '''Call to method that expects an Abstract argument.''' - objId = 123 - d = OtherDerived(objId) - self.assertEqual(Abstract.getObjectId(d), objId) - -if __name__ == '__main__': - unittest.main() - diff --git a/sources/shiboken2/tests/otherbinding/signature_test.py b/sources/shiboken2/tests/otherbinding/signature_test.py deleted file mode 100644 index f3b712d04..000000000 --- a/sources/shiboken2/tests/otherbinding/signature_test.py +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# -############################################################################# -## -## Copyright (C) 2019 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$ -## -############################################################################# - -'''Test cases for functions signature''' - -import os -import sys -import unittest - -sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) -from shiboken_paths import init_paths -init_paths() - -from other import OtherObjectType -from shiboken_test_helper import objectFullname - -class SignatureTest(unittest.TestCase): - - # Check if the argument of 'OtherObjectType::enumAsInt(SampleNamespace::SomeClass::PublicScopedEnum value)' - # has the correct representation - def testNamespaceFromOtherModule(self): - argType = OtherObjectType.enumAsInt.__signature__.parameters['value'].annotation - self.assertEqual(objectFullname(argType), 'sample.SampleNamespace.SomeClass.PublicScopedEnum') - -if __name__ == '__main__': - unittest.main() diff --git a/sources/shiboken2/tests/otherbinding/smartptr_test.py b/sources/shiboken2/tests/otherbinding/smartptr_test.py deleted file mode 100644 index 04f657757..000000000 --- a/sources/shiboken2/tests/otherbinding/smartptr_test.py +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# -############################################################################# -## -## Copyright (C) 2020 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$ -## -############################################################################# - -'''Test cases for the SmartPtrTester class''' - -import os -import sys -import unittest - -sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) -from shiboken_paths import init_paths -init_paths() - -from smart import Integer -from sample import Str -from other import SmartPtrTester - - -class SmartPtrTest(unittest.TestCase): - '''Test case for the SmartPtrTester class''' - - def test(self): - tester = SmartPtrTester() - - integerPtr = tester.createSharedPtrInteger(42) - self.assertEqual(tester.valueOfSharedPtrInteger(integerPtr), 42) - - strPtr = tester.createSharedPtrStr('hello') - self.assertEqual(tester.valueOfSharedPtrStr(strPtr), 'hello') - - -if __name__ == '__main__': - unittest.main() diff --git a/sources/shiboken2/tests/otherbinding/test_module_template.py b/sources/shiboken2/tests/otherbinding/test_module_template.py deleted file mode 100644 index 5d08944f3..000000000 --- a/sources/shiboken2/tests/otherbinding/test_module_template.py +++ /dev/null @@ -1,40 +0,0 @@ -############################################################################# -## -## 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$ -## -############################################################################# - -from other import * -from sample import * - - -class MyObjectType(ObjectType): - pass - -class MyOtherObjectType(OtherObjectType): - value = 10 - - -obj = MyObjectType() diff --git a/sources/shiboken2/tests/otherbinding/typediscovery_test.py b/sources/shiboken2/tests/otherbinding/typediscovery_test.py deleted file mode 100644 index 200d091b0..000000000 --- a/sources/shiboken2/tests/otherbinding/typediscovery_test.py +++ /dev/null @@ -1,72 +0,0 @@ -#!/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$ -## -############################################################################# - -'''Test cases for type discovery''' - -import os -import sys -import unittest - -sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) -from shiboken_paths import init_paths -init_paths() - -from sample import Abstract, Base1, Derived, MDerived1, MDerived3, SonOfMDerived1 -from other import OtherMultipleDerived - -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) - # PYSIDE-868: In case of multiple inheritance, a factory - # function will return the base class wrapper. - obj = OtherMultipleDerived.createObject("MDerived1"); - self.assertEqual(type(obj), Base1) - obj = OtherMultipleDerived.createObject("SonOfMDerived1"); - self.assertEqual(type(obj), Base1) - obj = OtherMultipleDerived.createObject("MDerived3"); - self.assertEqual(type(obj), Base1) - obj = OtherMultipleDerived.createObject("OtherMultipleDerived"); - self.assertEqual(type(obj), Base1) - -if __name__ == '__main__': - unittest.main() diff --git a/sources/shiboken2/tests/otherbinding/typesystem_other.xml b/sources/shiboken2/tests/otherbinding/typesystem_other.xml deleted file mode 100644 index 78c4dd016..000000000 --- a/sources/shiboken2/tests/otherbinding/typesystem_other.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<typesystem package="other"> - <load-typesystem name="typesystem_sample.xml" generate="no" /> - <load-typesystem name="typesystem_smart.xml" generate="no" /> - - <object-type name="OtherObjectType" /> - <object-type name="OtherDerived" /> - <object-type name="OtherMultipleDerived" /> - - <value-type name="ExtendsNoImplicitConversion" /> - <value-type name="Number" /> - - <smart-pointer-type name="SharedPtr" type="shared" getter="data" ref-count-method="useCount" - instantiations="Str"/> - <value-type name="SmartPtrTester"/> - - <suppress-warning text="signature 'operator!=(ByteArray,const char*)' for function modification in 'ByteArray' not found." /> - <suppress-warning text="signature 'operator+(ByteArray,const char*)' for function modification in 'ByteArray' not found." /> - <suppress-warning text="signature 'operator==(ByteArray,const char*)' for function modification in 'ByteArray' not found." /> -</typesystem> diff --git a/sources/shiboken2/tests/otherbinding/usersprimitivefromothermodule_test.py b/sources/shiboken2/tests/otherbinding/usersprimitivefromothermodule_test.py deleted file mode 100644 index a69ee23f0..000000000 --- a/sources/shiboken2/tests/otherbinding/usersprimitivefromothermodule_test.py +++ /dev/null @@ -1,58 +0,0 @@ -#!/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$ -## -############################################################################# - -'''Tests user defined primitive type from a required module.''' - -import os -import sys -import unittest - -sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) -from shiboken_paths import init_paths -init_paths() -from other import Number - -class UserDefinedPrimitiveTypeFromRequiredModuleTest(unittest.TestCase): - - def testUsersPrimitiveFromRequiredModuleAsArgument(self): - '''static Number Number::fromComplex(Complex)''' - cpx = complex(3.0, 1.2) - number = Number.fromComplex(cpx) - self.assertEqual(number.value(), int(cpx.real)) - - def testUsersPrimitiveFromRequiredModuleAsReturnValue(self): - '''Complex Number::toComplex()''' - number = Number(12) - cpx = number.toComplex() - self.assertEqual(number.value(), int(cpx.real)) - -if __name__ == '__main__': - unittest.main() diff --git a/sources/shiboken2/tests/otherbinding/wrongctor_test.py b/sources/shiboken2/tests/otherbinding/wrongctor_test.py deleted file mode 100644 index 29d085315..000000000 --- a/sources/shiboken2/tests/otherbinding/wrongctor_test.py +++ /dev/null @@ -1,59 +0,0 @@ -#!/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$ -## -############################################################################# - -import os -import sys -import unittest - -sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) -from shiboken_paths import init_paths -init_paths() -from sample import * -from other import * - -class Foo(OtherDerived): - def __init__(self): - Abstract.__init__(self, 2) # this should raise an exception - -class Foo2(ObjectType, OtherDerived): - def __init__(self): - ObjectType.__init__(self) - Abstract.__init__(self, 2) # this should raise an exception - - -class WrongCtorTest(unittest.TestCase): - def testIt(self): - self.assertRaises(TypeError, Foo) - self.assertRaises(TypeError, Foo2) - - -if __name__ == '__main__': - unittest.main() |