diff options
author | Friedemann Kleint <[email protected]> | 2024-12-19 14:01:40 +0100 |
---|---|---|
committer | Friedemann Kleint <[email protected]> | 2024-12-20 10:14:57 +0100 |
commit | a88b7fc378bfa2481e581adc9de981dbd263ddc4 (patch) | |
tree | d7deaf90fa9bc171ee52d909071daaf2ec2d7dde /sources | |
parent | 6eb75a26498f8984345fcdd5434b6758819f0d7f (diff) |
shiboken6/tests: Use fully qualified enumerations
Pick-to: 6.8
Task-number: PYSIDE-1735
Change-Id: I5a907b536b36521eb6dd5fcdc1ad1094bb031aa8
Reviewed-by: Shyamnath Premnadh <[email protected]>
Diffstat (limited to 'sources')
24 files changed, 206 insertions, 189 deletions
diff --git a/sources/shiboken6/tests/minimalbinding/val_test.py b/sources/shiboken6/tests/minimalbinding/val_test.py index 25642dc3f..b84bb1eb7 100644 --- a/sources/shiboken6/tests/minimalbinding/val_test.py +++ b/sources/shiboken6/tests/minimalbinding/val_test.py @@ -58,8 +58,8 @@ class ValTest(unittest.TestCase): def testPassAndReceiveEnumValue(self): val = Val(0) - self.assertEqual(val.oneOrTheOtherEnumValue(Val.One), Val.Other) - self.assertEqual(val.oneOrTheOtherEnumValue(Val.Other), Val.One) + self.assertEqual(val.oneOrTheOtherEnumValue(Val.ValEnum.One), Val.ValEnum.Other) + self.assertEqual(val.oneOrTheOtherEnumValue(Val.ValEnum.Other), Val.ValEnum.One) def testPassValueTypeFromExtendedClass(self): val = ExtVal(0) diff --git a/sources/shiboken6/tests/samplebinding/abstract_test.py b/sources/shiboken6/tests/samplebinding/abstract_test.py index bf7f36dfb..f9ccd0b12 100644 --- a/sources/shiboken6/tests/samplebinding/abstract_test.py +++ b/sources/shiboken6/tests/samplebinding/abstract_test.py @@ -80,7 +80,7 @@ class AbstractTest(unittest.TestCase): def testEnumParameterOnVirtualMethodCall(self): '''testEnumParameterOnVirtualMethodCall''' c = Concrete() - c.callVirtualGettingEnum(Abstract.Short) + c.callVirtualGettingEnum(Abstract.PrintFormat.Short) self.assertTrue(c.virtual_getting_enum) diff --git a/sources/shiboken6/tests/samplebinding/decisor_test.py b/sources/shiboken6/tests/samplebinding/decisor_test.py index 9db6342a1..9aeeeed20 100644 --- a/sources/shiboken6/tests/samplebinding/decisor_test.py +++ b/sources/shiboken6/tests/samplebinding/decisor_test.py @@ -40,13 +40,13 @@ class DecisorTest(unittest.TestCase): objecttype = ObjectType() objectmodel = ObjectModel() self.assertEqual(ObjectModel.receivesObjectTypeFamily(objecttype), - ObjectModel.ObjectTypeCalled) + ObjectModel.MethodCalled.ObjectTypeCalled) self.assertNotEqual(ObjectModel.receivesObjectTypeFamily(objecttype), - ObjectModel.ObjectModelCalled) + ObjectModel.MethodCalled.ObjectModelCalled) self.assertEqual(ObjectModel.receivesObjectTypeFamily(objectmodel), - ObjectModel.ObjectModelCalled) + ObjectModel.MethodCalled.ObjectModelCalled) self.assertNotEqual(ObjectModel.receivesObjectTypeFamily(objectmodel), - ObjectModel.ObjectTypeCalled) + ObjectModel.MethodCalled.ObjectTypeCalled) if __name__ == '__main__': diff --git a/sources/shiboken6/tests/samplebinding/derived_test.py b/sources/shiboken6/tests/samplebinding/derived_test.py index 834d3416a..b251ce8c7 100644 --- a/sources/shiboken6/tests/samplebinding/derived_test.py +++ b/sources/shiboken6/tests/samplebinding/derived_test.py @@ -58,11 +58,11 @@ class DerivedTest(unittest.TestCase): result = derived.otherOverloaded(1, 2, True, 3.3) self.assertEqual(type(result), Derived.OtherOverloadedFuncEnum) - self.assertEqual(result, sample.Derived.OtherOverloadedFunc_iibd) + self.assertEqual(result, sample.Derived.OtherOverloadedFuncEnum.OtherOverloadedFunc_iibd) result = derived.otherOverloaded(1, 2.2) self.assertEqual(type(result), Derived.OtherOverloadedFuncEnum) - self.assertEqual(result, Derived.OtherOverloadedFunc_id) + self.assertEqual(result, Derived.OtherOverloadedFuncEnum.OtherOverloadedFunc_id) def testOverloadedMethodCallWithDifferentNumericTypes(self): '''Test if the correct overloaded method accepts a different numeric type as argument.''' diff --git a/sources/shiboken6/tests/samplebinding/enum_test.py b/sources/shiboken6/tests/samplebinding/enum_test.py index 50bf4a61d..d4369b420 100644 --- a/sources/shiboken6/tests/samplebinding/enum_test.py +++ b/sources/shiboken6/tests/samplebinding/enum_test.py @@ -29,8 +29,9 @@ class EnumTest(unittest.TestCase): '''Test case for Python representation of C++ enums.''' def testHashability(self): - self.assertEqual(hash(SampleNamespace.TwoIn), hash(SampleNamespace.TwoOut)) - self.assertNotEqual(hash(SampleNamespace.TwoIn), hash(SampleNamespace.OneIn)) + self.assertEqual(hash(SampleNamespace.InValue.TwoIn), hash(SampleNamespace.OutValue.TwoOut)) + self.assertNotEqual(hash(SampleNamespace.InValue.TwoIn), + hash(SampleNamespace.InValue.OneIn)) def testEnumValuesInsideEnum(self): '''Enum values should be accessible inside the enum as well as outside.''' @@ -50,13 +51,13 @@ class EnumTest(unittest.TestCase): def testBuildingEnumWithDefaultValue(self): '''Enum constructor with default value''' enum = SampleNamespace.Option() - self.assertEqual(enum, SampleNamespace.None_) + self.assertEqual(enum, SampleNamespace.Option.None_) def testEnumConversionToAndFromPython(self): '''Conversion of enum objects from Python to C++ back again.''' - enumout = SampleNamespace.enumInEnumOut(SampleNamespace.TwoIn) - self.assertTrue(enumout, SampleNamespace.TwoOut) - self.assertEqual(repr(enumout), repr(SampleNamespace.TwoOut)) + enumout = SampleNamespace.enumInEnumOut(SampleNamespace.InValue.TwoIn) + self.assertTrue(enumout, SampleNamespace.OutValue.TwoOut) + self.assertEqual(repr(enumout), repr(SampleNamespace.OutValue.TwoOut)) def testEnumConstructorWithTooManyParameters(self): '''Calling the constructor of non-extensible enum with the wrong number of parameters.''' @@ -69,9 +70,9 @@ class EnumTest(unittest.TestCase): def testEnumItemAsDefaultValueToIntArgument(self): '''Calls function with an enum item as default value to an int argument.''' self.assertEqual(SampleNamespace.enumItemAsDefaultValueToIntArgument(), - SampleNamespace.ZeroIn) - self.assertEqual(SampleNamespace.enumItemAsDefaultValueToIntArgument(SampleNamespace.ZeroOut), # noqa E:501 - SampleNamespace.ZeroOut) + SampleNamespace.InValue.ZeroIn) + self.assertEqual(SampleNamespace.enumItemAsDefaultValueToIntArgument(SampleNamespace.OutValue.ZeroOut), # noqa E:501 + SampleNamespace.OutValue.ZeroOut) self.assertEqual(SampleNamespace.enumItemAsDefaultValueToIntArgument(123), 123) def testAnonymousGlobalEnums(self): @@ -90,20 +91,21 @@ class EnumTest(unittest.TestCase): self.assertEqual(sum, 1) def testSetEnum(self): - event = Event(Event.ANY_EVENT) - self.assertEqual(event.eventType(), Event.ANY_EVENT) - event.setEventType(Event.BASIC_EVENT) - self.assertEqual(event.eventType(), Event.BASIC_EVENT) - event.setEventTypeByConstRef(Event.SOME_EVENT) - self.assertEqual(event.eventType(), Event.SOME_EVENT) - event.setEventTypeByConstPtr(Event.BASIC_EVENT) - self.assertEqual(event.eventType(), Event.BASIC_EVENT) + event = Event(Event.EventType.ANY_EVENT) + self.assertEqual(event.eventType(), Event.EventType.ANY_EVENT) + event.setEventType(Event.EventType.BASIC_EVENT) + self.assertEqual(event.eventType(), Event.EventType.BASIC_EVENT) + event.setEventTypeByConstRef(Event.EventType.SOME_EVENT) + self.assertEqual(event.eventType(), Event.EventType.SOME_EVENT) + event.setEventTypeByConstPtr(Event.EventType.BASIC_EVENT) + self.assertEqual(event.eventType(), Event.EventType.BASIC_EVENT) def testEnumArgumentWithDefaultValue(self): '''Option enumArgumentWithDefaultValue(Option opt = UnixTime);''' - self.assertEqual(SampleNamespace.enumArgumentWithDefaultValue(), SampleNamespace.UnixTime) - self.assertEqual(SampleNamespace.enumArgumentWithDefaultValue(SampleNamespace.RandomNumber), # noqa E:501 - SampleNamespace.RandomNumber) + self.assertEqual(SampleNamespace.enumArgumentWithDefaultValue(), + SampleNamespace.Option.UnixTime) + self.assertEqual(SampleNamespace.enumArgumentWithDefaultValue(SampleNamespace.Option.RandomNumber), # noqa E:501 + SampleNamespace.Option.RandomNumber) class MyEvent(Event): @@ -124,7 +126,7 @@ class EnumOverloadTest(unittest.TestCase): '''Overload with Enums and ints with default value''' o = ObjectType() - self.assertEqual(o.callWithEnum('', Event.ANY_EVENT, 9), 81) + self.assertEqual(o.callWithEnum('', Event.EventType.ANY_EVENT, 9), 81) self.assertEqual(o.callWithEnum('', 9), 9) @@ -132,7 +134,8 @@ class EnumOperators(unittest.TestCase): '''Test case for operations on enums''' def testInequalitySameObject(self): - self.assertFalse(Event.ANY_EVENT != Event.ANY_EVENT) + self.assertFalse(Event.EventType.ANY_EVENT + != Event.EventType.ANY_EVENT) if __name__ == '__main__': diff --git a/sources/shiboken6/tests/samplebinding/enumfromremovednamespace_test.py b/sources/shiboken6/tests/samplebinding/enumfromremovednamespace_test.py index f88d6c3d8..5696f968a 100644 --- a/sources/shiboken6/tests/samplebinding/enumfromremovednamespace_test.py +++ b/sources/shiboken6/tests/samplebinding/enumfromremovednamespace_test.py @@ -41,7 +41,7 @@ class TestEnumFromRemovedNamespace(unittest.TestCase): def testEnumPromotedToUpperNamespace(self): sample.UnremovedNamespace sample.UnremovedNamespace.RemovedNamespace3_Enum - sample.UnremovedNamespace.RemovedNamespace3_Enum_Value0 + sample.UnremovedNamespace.RemovedNamespace3_Enum.RemovedNamespace3_Enum_Value0 sample.UnremovedNamespace.RemovedNamespace3_AnonymousEnum_Value0 def testNestedFunctionFromRemovedNamespace(self): diff --git a/sources/shiboken6/tests/samplebinding/event_loop_call_virtual_test.py b/sources/shiboken6/tests/samplebinding/event_loop_call_virtual_test.py index c2b6200d0..f9286dd22 100644 --- a/sources/shiboken6/tests/samplebinding/event_loop_call_virtual_test.py +++ b/sources/shiboken6/tests/samplebinding/event_loop_call_virtual_test.py @@ -40,7 +40,7 @@ class TestEventLoop(unittest.TestCase): objs = [ObjectType(), NoOverride(), Override()] evaluated = ObjectType.processEvent(objs, - Event(Event.BASIC_EVENT)) + Event(Event.EventType.BASIC_EVENT)) self.assertEqual(evaluated, 3) self.assertTrue(objs[2].called) diff --git a/sources/shiboken6/tests/samplebinding/event_loop_thread_test.py b/sources/shiboken6/tests/samplebinding/event_loop_thread_test.py index 5a8d32bce..1276eb050 100644 --- a/sources/shiboken6/tests/samplebinding/event_loop_thread_test.py +++ b/sources/shiboken6/tests/samplebinding/event_loop_thread_test.py @@ -65,7 +65,7 @@ class TestEventLoopWithThread(unittest.TestCase): thread.start() evaluated = ObjectType.processEvent(objs, - Event(Event.BASIC_EVENT)) + Event(Event.EventType.BASIC_EVENT)) thread.join() diff --git a/sources/shiboken6/tests/samplebinding/filter_test.py b/sources/shiboken6/tests/samplebinding/filter_test.py index a0c631a37..e5c1e9f9f 100644 --- a/sources/shiboken6/tests/samplebinding/filter_test.py +++ b/sources/shiboken6/tests/samplebinding/filter_test.py @@ -18,7 +18,7 @@ class TestFilters(unittest.TestCase): def testAnd(self): - f1 = Data(Data.Name, "joe") + f1 = Data(Data.Field.Name, "joe") f2 = Union() inter = f1 & f2 diff --git a/sources/shiboken6/tests/samplebinding/implicitconv_test.py b/sources/shiboken6/tests/samplebinding/implicitconv_test.py index 4dde6c786..f6622fb34 100644 --- a/sources/shiboken6/tests/samplebinding/implicitconv_test.py +++ b/sources/shiboken6/tests/samplebinding/implicitconv_test.py @@ -23,24 +23,24 @@ class ImplicitConvTest(unittest.TestCase): def testImplicitConversions(self): '''Test if overloaded function call decisor takes implicit conversions into account.''' ic = ImplicitConv.implicitConvCommon(ImplicitConv()) - self.assertEqual(ic.ctorEnum(), ImplicitConv.CtorNone) + self.assertEqual(ic.ctorEnum(), ImplicitConv.CtorEnum.CtorNone) ic = ImplicitConv.implicitConvCommon(3) - self.assertEqual(ic.ctorEnum(), ImplicitConv.CtorOne) + self.assertEqual(ic.ctorEnum(), ImplicitConv.CtorEnum.CtorOne) self.assertEqual(ic.objId(), 3) - ic = ImplicitConv.implicitConvCommon(ImplicitConv.CtorThree) - self.assertEqual(ic.ctorEnum(), ImplicitConv.CtorThree) + ic = ImplicitConv.implicitConvCommon(ImplicitConv.CtorEnum.CtorThree) + self.assertEqual(ic.ctorEnum(), ImplicitConv.CtorEnum.CtorThree) obj = ObjectType() ic = ImplicitConv.implicitConvCommon(obj) - self.assertEqual(ic.ctorEnum(), ImplicitConv.CtorObjectTypeReference) + self.assertEqual(ic.ctorEnum(), ImplicitConv.CtorEnum.CtorObjectTypeReference) ic = ImplicitConv.implicitConvCommon(42.42) self.assertEqual(ic.value(), 42.42) ic = ImplicitConv(None) - self.assertEqual(ic.ctorEnum(), ImplicitConv.CtorPrimitiveType) + self.assertEqual(ic.ctorEnum(), ImplicitConv.CtorEnum.CtorPrimitiveType) if __name__ == '__main__': diff --git a/sources/shiboken6/tests/samplebinding/intlist_test.py b/sources/shiboken6/tests/samplebinding/intlist_test.py index 813ff4126..f062b53c7 100644 --- a/sources/shiboken6/tests/samplebinding/intlist_test.py +++ b/sources/shiboken6/tests/samplebinding/intlist_test.py @@ -36,7 +36,7 @@ class IntListTest(unittest.TestCase): '''IntList constructor receives no parameter.''' il = IntList() self.assertEqual(len(il), 0) - self.assertEqual(il.constructorUsed(), IntList.NoParamsCtor) + self.assertEqual(il.constructorUsed(), IntList.CtorEnum.NoParamsCtor) def testIntListCtor_int(self): '''IntList constructor receives an integer.''' @@ -44,7 +44,7 @@ class IntListTest(unittest.TestCase): il = IntList(value) self.assertEqual(len(il), 1) self.assertEqual(il[0], value) - self.assertEqual(il.constructorUsed(), IntList.IntCtor) + self.assertEqual(il.constructorUsed(), IntList.CtorEnum.IntCtor) def testIntListCtor_IntList(self): '''IntList constructor receives an IntList object.''' @@ -53,7 +53,7 @@ class IntListTest(unittest.TestCase): self.assertEqual(len(il1), len(il2)) for i in range(len(il1)): self.assertEqual(il1[i], il2[i]) - self.assertEqual(il2.constructorUsed(), IntList.CopyCtor) + self.assertEqual(il2.constructorUsed(), IntList.CtorEnum.CopyCtor) def testIntListCtor_ListOfInts(self): '''IntList constructor receives an integer list.''' @@ -62,7 +62,7 @@ class IntListTest(unittest.TestCase): self.assertEqual(len(il), len(ints)) for i in range(len(il)): self.assertEqual(il[i], ints[i]) - self.assertEqual(il.constructorUsed(), IntList.ListOfIntCtor) + self.assertEqual(il.constructorUsed(), IntList.CtorEnum.ListOfIntCtor) def testIntListAttributeTypeCheck(self): '''Attribute values to IntList.''' diff --git a/sources/shiboken6/tests/samplebinding/mi_virtual_methods_test.py b/sources/shiboken6/tests/samplebinding/mi_virtual_methods_test.py index c5043c8b3..02e3b1ba7 100644 --- a/sources/shiboken6/tests/samplebinding/mi_virtual_methods_test.py +++ b/sources/shiboken6/tests/samplebinding/mi_virtual_methods_test.py @@ -47,7 +47,7 @@ class CppVirtualTest(unittest.TestCase): def testCpp(self): '''C++ calling C++ virtual method in multiple inheritance scenario''' obj = ImplementsNone() - self.assertTrue(ObjectType.processEvent([obj], Event(Event.BASIC_EVENT))) + self.assertTrue(ObjectType.processEvent([obj], Event(Event.EventType.BASIC_EVENT))) self.assertRaises(AttributeError, getattr, obj, 'event_processed') self.assertEqual(obj.callSum0(1, 2, 3), 6) @@ -59,7 +59,7 @@ class PyVirtualTest(unittest.TestCase): def testEvent(self): '''C++ calling Python reimplementation of virtual in multiple inheritance''' obj = ImplementsBoth() - self.assertTrue(ObjectType.processEvent([obj], Event(Event.BASIC_EVENT))) + self.assertTrue(ObjectType.processEvent([obj], Event(Event.EventType.BASIC_EVENT))) self.assertTrue(obj.event_processed) self.assertEqual(obj.callSum1(1, 2, 3), 12) diff --git a/sources/shiboken6/tests/samplebinding/modifications_test.py b/sources/shiboken6/tests/samplebinding/modifications_test.py index ccd6747d7..3d9ffa232 100644 --- a/sources/shiboken6/tests/samplebinding/modifications_test.py +++ b/sources/shiboken6/tests/samplebinding/modifications_test.py @@ -116,16 +116,19 @@ class ModificationsTest(unittest.TestCase): def testOverloadedMethodModifications(self): '''Tests modifications to an overloaded method''' # overloaded(int, bool[removed], int, double) - self.assertEqual(self.mods.overloaded(1, 2, 3.1), Modifications.Overloaded_ibid) + self.assertEqual(self.mods.overloaded(1, 2, 3.1), + Modifications.OverloadedModFunc.Overloaded_ibid) # overloaded(int, bool, int[removed,default=321], int) - self.assertEqual(self.mods.overloaded(1, True, 2), Modifications.Overloaded_ibii) + self.assertEqual(self.mods.overloaded(1, True, 2), + Modifications.OverloadedModFunc.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, True, 2, False), + Modifications.OverloadedModFunc.Overloaded_ibib) self.assertEqual(self.mods.overloaded(1, False, 2, Point(3, 4)), - Modifications.Overloaded_ibiP) + Modifications.OverloadedModFunc.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) + Modifications.OverloadedModFunc.Overloaded_ibPP) def testPointArrayModification(self): points = (Point(1, 1), Point(2, 2)) @@ -210,7 +213,7 @@ class ModificationsTest(unittest.TestCase): # qualified by the enum scope. modifications = Modifications() modifications.setEnumValue() - self.assertEqual(modifications.enumValue(), Modifications.TestEnumValue2) + self.assertEqual(modifications.enumValue(), Modifications.TestEnum.TestEnumValue2) def testSetGetAttro(self): modifications = Modifications() diff --git a/sources/shiboken6/tests/samplebinding/namespace_test.py b/sources/shiboken6/tests/samplebinding/namespace_test.py index 0d0dc7f33..0d67c7497 100644 --- a/sources/shiboken6/tests/samplebinding/namespace_test.py +++ b/sources/shiboken6/tests/samplebinding/namespace_test.py @@ -61,8 +61,8 @@ class TestClassesUnderNamespace(unittest.TestCase): def testInlineNamespaces(self): cls = SampleNamespace.ClassWithinInlineNamespace() - cls.setValue(SampleNamespace.EWIN_Value1) - self.assertEqual(cls.value(), SampleNamespace.EWIN_Value1) + cls.setValue(SampleNamespace.EnumWithinInlineNamespace.EWIN_Value1) + self.assertEqual(cls.value(), SampleNamespace.EnumWithinInlineNamespace.EWIN_Value1) if __name__ == '__main__': diff --git a/sources/shiboken6/tests/samplebinding/oddbool_test.py b/sources/shiboken6/tests/samplebinding/oddbool_test.py index 31db7bc6f..2d48556de 100644 --- a/sources/shiboken6/tests/samplebinding/oddbool_test.py +++ b/sources/shiboken6/tests/samplebinding/oddbool_test.py @@ -63,7 +63,7 @@ class OddBoolTest(unittest.TestCase): self.assertEqual(t1, t2) def testSpaceshipOperator(self): - if not SpaceshipComparisonTester.HasSpaceshipOperator: + if not SpaceshipComparisonTester.Enabled.HasSpaceshipOperator: print("Skipping Spaceship Operator test") return t1 = SpaceshipComparisonTester(42) diff --git a/sources/shiboken6/tests/samplebinding/overload_sorting_test.py b/sources/shiboken6/tests/samplebinding/overload_sorting_test.py index df4fdc010..1b63aa33e 100644 --- a/sources/shiboken6/tests/samplebinding/overload_sorting_test.py +++ b/sources/shiboken6/tests/samplebinding/overload_sorting_test.py @@ -70,8 +70,8 @@ class DeepOverloadSorting(unittest.TestCase): class EnumOverIntSorting(unittest.TestCase): def testEnumOverInt(self): - ic = ImplicitConv(ImplicitConv.CtorTwo) - self.assertEqual(ic.ctorEnum(), ImplicitConv.CtorTwo) + ic = ImplicitConv(ImplicitConv.CtorEnum.CtorTwo) + self.assertEqual(ic.ctorEnum(), ImplicitConv.CtorEnum.CtorTwo) class TestCustomOverloadSequence(unittest.TestCase): diff --git a/sources/shiboken6/tests/samplebinding/overload_test.py b/sources/shiboken6/tests/samplebinding/overload_test.py index 95a313df0..e68bd0aad 100644 --- a/sources/shiboken6/tests/samplebinding/overload_test.py +++ b/sources/shiboken6/tests/samplebinding/overload_test.py @@ -35,32 +35,33 @@ class OverloadTest(unittest.TestCase): def testOverloadMethod0(self): '''Check overloaded method call for signature "overloaded()".''' overload = Overload() - self.assertEqual(overload.overloaded(), Overload.Function0) + self.assertEqual(overload.overloaded(), Overload.FunctionEnum.Function0) def testOverloadMethod1(self): '''Check overloaded method call for signature "overloaded(Size*)".''' overload = Overload() size = Size() - self.assertEqual(overload.overloaded(size), Overload.Function1) + self.assertEqual(overload.overloaded(size), Overload.FunctionEnum.Function1) def testOverloadMethod2(self): '''Check overloaded method call for signature "overloaded(Point*, ParamEnum)".''' overload = Overload() point = Point() - self.assertEqual(overload.overloaded(point, Overload.Param1), Overload.Function2) + self.assertEqual(overload.overloaded(point, Overload.ParamEnum.Param1), + Overload.FunctionEnum.Function2) def testOverloadMethod3(self): '''Check overloaded method call for signature "overloaded(const Point&)".''' overload = Overload() point = Point() - self.assertEqual(overload.overloaded(point), Overload.Function3) + self.assertEqual(overload.overloaded(point), Overload.FunctionEnum.Function3) def testDifferentReturnTypes(self): '''Check method calls for overloads with different return types.''' overload = Overload() self.assertEqual(overload.differentReturnTypes(), None) - self.assertEqual(overload.differentReturnTypes(Overload.Param1), None) - self.assertEqual(overload.differentReturnTypes(Overload.Param0, 13), 13) + self.assertEqual(overload.differentReturnTypes(Overload.ParamEnum.Param1), None) + self.assertEqual(overload.differentReturnTypes(Overload.ParamEnum.Param0, 13), 13) def testIntOverloads(self): overload = Overload() @@ -70,65 +71,67 @@ class OverloadTest(unittest.TestCase): def testIntDoubleOverloads(self): overload = Overload() - self.assertEqual(overload.intDoubleOverloads(1, 2), Overload.Function0) - self.assertEqual(overload.intDoubleOverloads(1, 2.0), Overload.Function0) - self.assertEqual(overload.intDoubleOverloads(1.0, 2), Overload.Function1) - self.assertEqual(overload.intDoubleOverloads(1.0, 2.0), Overload.Function1) + self.assertEqual(overload.intDoubleOverloads(1, 2), Overload.FunctionEnum.Function0) + self.assertEqual(overload.intDoubleOverloads(1, 2.0), Overload.FunctionEnum.Function0) + self.assertEqual(overload.intDoubleOverloads(1.0, 2), Overload.FunctionEnum.Function1) + self.assertEqual(overload.intDoubleOverloads(1.0, 2.0), Overload.FunctionEnum.Function1) def testWrapperIntIntOverloads(self): overload = Overload() - self.assertEqual(overload.wrapperIntIntOverloads(Point(), 1, 2), Overload.Function0) - self.assertEqual(overload.wrapperIntIntOverloads(Polygon(), 1, 2), Overload.Function1) + self.assertEqual(overload.wrapperIntIntOverloads(Point(), 1, 2), + Overload.FunctionEnum.Function0) + self.assertEqual(overload.wrapperIntIntOverloads(Polygon(), 1, 2), + Overload.FunctionEnum.Function1) def testDrawTextPointAndStr(self): overload = Overload() - self.assertEqual(overload.drawText(Point(), Str()), Overload.Function0) - self.assertEqual(overload.drawText(Point(), ''), Overload.Function0) - self.assertEqual(overload.drawText(PointF(), Str()), Overload.Function1) - self.assertEqual(overload.drawText(PointF(), ''), Overload.Function1) + self.assertEqual(overload.drawText(Point(), Str()), Overload.FunctionEnum.Function0) + self.assertEqual(overload.drawText(Point(), ''), Overload.FunctionEnum.Function0) + self.assertEqual(overload.drawText(PointF(), Str()), Overload.FunctionEnum.Function1) + self.assertEqual(overload.drawText(PointF(), ''), Overload.FunctionEnum.Function1) def testDrawTextRectIntStr(self): overload = Overload() - self.assertEqual(overload.drawText(Rect(), 1, Str()), Overload.Function2) - self.assertEqual(overload.drawText(Rect(), 1, ''), Overload.Function2) - self.assertEqual(overload.drawText(RectF(), 1, Str()), Overload.Function3) - self.assertEqual(overload.drawText(RectF(), 1, ''), Overload.Function3) + self.assertEqual(overload.drawText(Rect(), 1, Str()), Overload.FunctionEnum.Function2) + self.assertEqual(overload.drawText(Rect(), 1, ''), Overload.FunctionEnum.Function2) + self.assertEqual(overload.drawText(RectF(), 1, Str()), Overload.FunctionEnum.Function3) + self.assertEqual(overload.drawText(RectF(), 1, ''), Overload.FunctionEnum.Function3) def testDrawTextRectFStrEcho(self): overload = Overload() - self.assertEqual(overload.drawText(RectF(), Str()), Overload.Function4) - self.assertEqual(overload.drawText(RectF(), ''), Overload.Function4) - self.assertEqual(overload.drawText(RectF(), Str(), Echo()), Overload.Function4) - self.assertEqual(overload.drawText(RectF(), '', Echo()), Overload.Function4) - self.assertEqual(overload.drawText(Rect(), Str()), Overload.Function4) - self.assertEqual(overload.drawText(Rect(), ''), Overload.Function4) - self.assertEqual(overload.drawText(Rect(), Str(), Echo()), Overload.Function4) - self.assertEqual(overload.drawText(Rect(), '', Echo()), Overload.Function4) + self.assertEqual(overload.drawText(RectF(), Str()), Overload.FunctionEnum.Function4) + self.assertEqual(overload.drawText(RectF(), ''), Overload.FunctionEnum.Function4) + self.assertEqual(overload.drawText(RectF(), Str(), Echo()), Overload.FunctionEnum.Function4) + self.assertEqual(overload.drawText(RectF(), '', Echo()), Overload.FunctionEnum.Function4) + self.assertEqual(overload.drawText(Rect(), Str()), Overload.FunctionEnum.Function4) + self.assertEqual(overload.drawText(Rect(), ''), Overload.FunctionEnum.Function4) + self.assertEqual(overload.drawText(Rect(), Str(), Echo()), Overload.FunctionEnum.Function4) + self.assertEqual(overload.drawText(Rect(), '', Echo()), Overload.FunctionEnum.Function4) def testDrawTextIntIntStr(self): overload = Overload() - self.assertEqual(overload.drawText(1, 2, Str()), Overload.Function5) - self.assertEqual(overload.drawText(1, 2, ''), Overload.Function5) + self.assertEqual(overload.drawText(1, 2, Str()), Overload.FunctionEnum.Function5) + self.assertEqual(overload.drawText(1, 2, ''), Overload.FunctionEnum.Function5) def testDrawTextIntIntIntIntStr(self): overload = Overload() - self.assertEqual(overload.drawText(1, 2, 3, 4, 5, Str()), Overload.Function6) - self.assertEqual(overload.drawText(1, 2, 3, 4, 5, ''), Overload.Function6) + self.assertEqual(overload.drawText(1, 2, 3, 4, 5, Str()), Overload.FunctionEnum.Function6) + self.assertEqual(overload.drawText(1, 2, 3, 4, 5, ''), Overload.FunctionEnum.Function6) def testDrawText2IntIntIntIntStr(self): overload = Overload() - self.assertEqual(overload.drawText2(1, 2, 3, 4, 5, Str()), Overload.Function6) - self.assertEqual(overload.drawText2(1, 2, 3, 4, 5, ''), Overload.Function6) - self.assertEqual(overload.drawText2(1, 2, 3, 4, 5), Overload.Function6) - self.assertEqual(overload.drawText2(1, 2, 3, 4), Overload.Function6) - self.assertEqual(overload.drawText2(1, 2, 3), Overload.Function6) + self.assertEqual(overload.drawText2(1, 2, 3, 4, 5, Str()), Overload.FunctionEnum.Function6) + self.assertEqual(overload.drawText2(1, 2, 3, 4, 5, ''), Overload.FunctionEnum.Function6) + self.assertEqual(overload.drawText2(1, 2, 3, 4, 5), Overload.FunctionEnum.Function6) + self.assertEqual(overload.drawText2(1, 2, 3, 4), Overload.FunctionEnum.Function6) + self.assertEqual(overload.drawText2(1, 2, 3), Overload.FunctionEnum.Function6) def testDrawText3(self): overload = Overload() - self.assertEqual(overload.drawText3(Str(), Str(), Str()), Overload.Function0) - self.assertEqual(overload.drawText3('', '', ''), Overload.Function0) - self.assertEqual(overload.drawText3(1, 2, 3, 4, 5), Overload.Function1) - self.assertEqual(overload.drawText3(1, 2, 3, 4, 5), Overload.Function1) + self.assertEqual(overload.drawText3(Str(), Str(), Str()), Overload.FunctionEnum.Function0) + self.assertEqual(overload.drawText3('', '', ''), Overload.FunctionEnum.Function0) + self.assertEqual(overload.drawText3(1, 2, 3, 4, 5), Overload.FunctionEnum.Function1) + self.assertEqual(overload.drawText3(1, 2, 3, 4, 5), Overload.FunctionEnum.Function1) def testDrawText3Exception(self): overload = Overload() @@ -139,37 +142,39 @@ class OverloadTest(unittest.TestCase): def testDrawText4(self): overload = Overload() - self.assertEqual(overload.drawText4(1, 2, 3), Overload.Function0) - self.assertEqual(overload.drawText4(1, 2, 3, 4, 5), Overload.Function1) + self.assertEqual(overload.drawText4(1, 2, 3), Overload.FunctionEnum.Function0) + self.assertEqual(overload.drawText4(1, 2, 3, 4, 5), Overload.FunctionEnum.Function1) def testAcceptSequence(self): # Overload.acceptSequence() overload = Overload() - self.assertEqual(overload.acceptSequence(), Overload.Function0) + self.assertEqual(overload.acceptSequence(), Overload.FunctionEnum.Function0) def testAcceptSequenceIntInt(self): # Overload.acceptSequence(int,int) overload = Overload() - self.assertEqual(overload.acceptSequence(1, 2), Overload.Function1) + self.assertEqual(overload.acceptSequence(1, 2), Overload.FunctionEnum.Function1) def testAcceptSequenceStrParamEnum(self): # Overload.acceptSequence(Str,Overload::ParamEnum) overload = Overload() - self.assertEqual(overload.acceptSequence(''), Overload.Function2) - self.assertEqual(overload.acceptSequence('', Overload.Param0), Overload.Function2) - self.assertEqual(overload.acceptSequence(Str('')), Overload.Function2) - self.assertEqual(overload.acceptSequence(Str(''), Overload.Param0), Overload.Function2) + self.assertEqual(overload.acceptSequence(''), Overload.FunctionEnum.Function2) + self.assertEqual(overload.acceptSequence('', Overload.ParamEnum.Param0), + Overload.FunctionEnum.Function2) + self.assertEqual(overload.acceptSequence(Str('')), Overload.FunctionEnum.Function2) + self.assertEqual(overload.acceptSequence(Str(''), Overload.ParamEnum.Param0), + Overload.FunctionEnum.Function2) def testAcceptSequenceSize(self): # Overload.acceptSequence(Size) overload = Overload() - self.assertEqual(overload.acceptSequence(Size()), Overload.Function3) + self.assertEqual(overload.acceptSequence(Size()), Overload.FunctionEnum.Function3) def testAcceptSequenceStringList(self): # Overload.acceptSequence(const char**) overload = Overload() strings = ['line 1', 'line 2'] - self.assertEqual(overload.acceptSequence(strings), Overload.Function4) + self.assertEqual(overload.acceptSequence(strings), Overload.FunctionEnum.Function4) args = (['line 1', 2], ) result = raisesWithErrorMessage(overload.acceptSequence, args, TypeError, 'The argument must be a sequence of strings.') @@ -183,7 +188,7 @@ class OverloadTest(unittest.TestCase): pass foo = Foo() - self.assertEqual(overload.acceptSequence(foo), Overload.Function5) + self.assertEqual(overload.acceptSequence(foo), Overload.FunctionEnum.Function5) if __name__ == '__main__': diff --git a/sources/shiboken6/tests/samplebinding/overloadwithdefault_test.py b/sources/shiboken6/tests/samplebinding/overloadwithdefault_test.py index c55443529..07dee9623 100644 --- a/sources/shiboken6/tests/samplebinding/overloadwithdefault_test.py +++ b/sources/shiboken6/tests/samplebinding/overloadwithdefault_test.py @@ -19,26 +19,30 @@ class OverloadTest(unittest.TestCase): def testNoArgument(self): overload = Overload() - self.assertEqual(overload.strBufferOverloads(), Overload.Function2) + self.assertEqual(overload.strBufferOverloads(), Overload.FunctionEnum.Function2) def testStrArgument(self): overload = Overload() - self.assertEqual(overload.strBufferOverloads(Str('')), Overload.Function0) - self.assertEqual(overload.strBufferOverloads(Str(''), ''), Overload.Function0) - self.assertEqual(overload.strBufferOverloads(Str(''), '', False), Overload.Function0) + self.assertEqual(overload.strBufferOverloads(Str('')), Overload.FunctionEnum.Function0) + self.assertEqual(overload.strBufferOverloads(Str(''), ''), Overload.FunctionEnum.Function0) + self.assertEqual(overload.strBufferOverloads(Str(''), '', False), + Overload.FunctionEnum.Function0) def testStringArgumentAsStr(self): overload = Overload() - self.assertEqual(overload.strBufferOverloads('', ''), Overload.Function0) - self.assertEqual(overload.strBufferOverloads('', '', False), Overload.Function0) + self.assertEqual(overload.strBufferOverloads('', ''), Overload.FunctionEnum.Function0) + self.assertEqual(overload.strBufferOverloads('', '', False), + Overload.FunctionEnum.Function0) def testStringArgumentAsBuffer(self): overload = Overload() - self.assertEqual(overload.strBufferOverloads(bytes('', "UTF-8"), 0), Overload.Function1) + self.assertEqual(overload.strBufferOverloads(bytes('', "UTF-8"), 0), + Overload.FunctionEnum.Function1) def testBufferArgument(self): overload = Overload() - self.assertEqual(overload.strBufferOverloads(bytes('', "UTF-8"), 0), Overload.Function1) + self.assertEqual(overload.strBufferOverloads(bytes('', "UTF-8"), 0), + Overload.FunctionEnum.Function1) if __name__ == '__main__': diff --git a/sources/shiboken6/tests/samplebinding/ownership_invalidate_after_use_test.py b/sources/shiboken6/tests/samplebinding/ownership_invalidate_after_use_test.py index b62cf5e31..4c6baf00c 100644 --- a/sources/shiboken6/tests/samplebinding/ownership_invalidate_after_use_test.py +++ b/sources/shiboken6/tests/samplebinding/ownership_invalidate_after_use_test.py @@ -66,29 +66,29 @@ class OwnershipInvalidateAfterUseTest(unittest.TestCase): '''In ObjectType.event(Event*) the wrapper object created for Event must me marked as invalid after the method is called.''' eot = ExtObjectType() - eot.causeEvent(Event.SOME_EVENT) - self.assertEqual(eot.type_of_last_event, Event.SOME_EVENT) + eot.causeEvent(Event.EventType.SOME_EVENT) + self.assertEqual(eot.type_of_last_event, Event.EventType.SOME_EVENT) self.assertRaises(RuntimeError, eot.last_event.eventType) def testObjectInvalidatedAfterUseAsParameter(self): '''Tries to use wrapper invalidated after use as a parameter to another method.''' eot = ExtObjectType() ot = ObjectType() - eot.causeEvent(Event.ANY_EVENT) - self.assertEqual(eot.type_of_last_event, Event.ANY_EVENT) + eot.causeEvent(Event.EventType.ANY_EVENT) + self.assertEqual(eot.type_of_last_event, Event.EventType.ANY_EVENT) self.assertRaises(RuntimeError, ot.event, eot.last_event) def testit(self): obj = MyObjectType() - obj.causeEvent(Event.BASIC_EVENT) + obj.causeEvent(Event.EventType.BASIC_EVENT) self.assertFalse(obj.fail) def testInvalidateAfterUseInDerived(self): '''Invalidate was failing in a derived C++ class that also inherited other base classes''' eot = ExtObjectTypeDerived() - eot.causeEvent(Event.SOME_EVENT) - self.assertEqual(eot.type_of_last_event, Event.SOME_EVENT) + eot.causeEvent(Event.EventType.SOME_EVENT) + self.assertEqual(eot.type_of_last_event, Event.EventType.SOME_EVENT) self.assertRaises(RuntimeError, eot.last_event.eventType) diff --git a/sources/shiboken6/tests/samplebinding/pen_test.py b/sources/shiboken6/tests/samplebinding/pen_test.py index 922676f84..9bfc30728 100644 --- a/sources/shiboken6/tests/samplebinding/pen_test.py +++ b/sources/shiboken6/tests/samplebinding/pen_test.py @@ -25,7 +25,7 @@ class TestPen(unittest.TestCase): self.assertEqual(pen.ctorType(), Pen.EmptyCtor) def testPenWithEnumConstructor(self): - pen = Pen(SampleNamespace.RandomNumber) + pen = Pen(SampleNamespace.Option.RandomNumber) self.assertEqual(pen.ctorType(), Pen.EnumCtor) def testPenWithColorConstructor(self): diff --git a/sources/shiboken6/tests/samplebinding/protected_test.py b/sources/shiboken6/tests/samplebinding/protected_test.py index 05f72b673..319a564b4 100644 --- a/sources/shiboken6/tests/samplebinding/protected_test.py +++ b/sources/shiboken6/tests/samplebinding/protected_test.py @@ -216,14 +216,14 @@ class ExtendedProtectedEnumClass(ProtectedEnumClass): ProtectedEnumClass.__init__(self) def protectedEnumMethod(self, value): - if value == ProtectedEnumClass.ProtectedItem0: - return ProtectedEnumClass.ProtectedItem1 - return ProtectedEnumClass.ProtectedItem0 + if value == ProtectedEnumClass.ProtectedEnum.ProtectedItem0: + return ProtectedEnumClass.ProtectedEnum.ProtectedItem1 + return ProtectedEnumClass.ProtectedEnum.ProtectedItem0 def publicEnumMethod(self, value): - if value == ProtectedEnumClass.PublicItem0: - return ProtectedEnumClass.PublicItem1 - return ProtectedEnumClass.PublicItem0 + if value == ProtectedEnumClass.PublicEnum.PublicItem0: + return ProtectedEnumClass.PublicEnum.PublicItem1 + return ProtectedEnumClass.PublicEnum.PublicItem0 class ProtectedEnumTest(unittest.TestCase): @@ -238,68 +238,69 @@ class ProtectedEnumTest(unittest.TestCase): '''Calls protected method with protected enum argument.''' obj = ProtectedEnumClass() - self.assertEqual(type(ProtectedEnumClass.ProtectedItem0), ProtectedEnumClass.ProtectedEnum) + self.assertEqual(type(ProtectedEnumClass.ProtectedEnum.ProtectedItem0), + ProtectedEnumClass.ProtectedEnum) - self.assertEqual(obj.protectedEnumMethod(ProtectedEnumClass.ProtectedItem0), - ProtectedEnumClass.ProtectedItem0) - self.assertEqual(obj.protectedEnumMethod(ProtectedEnumClass.ProtectedItem1), - ProtectedEnumClass.ProtectedItem1) - self.assertEqual(obj.callProtectedEnumMethod(ProtectedEnumClass.ProtectedItem0), - ProtectedEnumClass.ProtectedItem0) - self.assertEqual(obj.callProtectedEnumMethod(ProtectedEnumClass.ProtectedItem1), - ProtectedEnumClass.ProtectedItem1) + self.assertEqual(obj.protectedEnumMethod(ProtectedEnumClass.ProtectedEnum.ProtectedItem0), + ProtectedEnumClass.ProtectedEnum.ProtectedItem0) + self.assertEqual(obj.protectedEnumMethod(ProtectedEnumClass.ProtectedEnum.ProtectedItem1), + ProtectedEnumClass.ProtectedEnum.ProtectedItem1) + self.assertEqual(obj.callProtectedEnumMethod(ProtectedEnumClass.ProtectedEnum.ProtectedItem0), # noqa: E501 + ProtectedEnumClass.ProtectedEnum.ProtectedItem0) + self.assertEqual(obj.callProtectedEnumMethod(ProtectedEnumClass.ProtectedEnum.ProtectedItem1), # noqa: E501 + ProtectedEnumClass.ProtectedEnum.ProtectedItem1) def testProtectedMethodWithPublicEnumArgument(self): '''Calls protected method with public enum argument.''' obj = ProtectedEnumClass() - self.assertEqual(obj.publicEnumMethod(ProtectedEnumClass.PublicItem0), - ProtectedEnumClass.PublicItem0) - self.assertEqual(obj.publicEnumMethod(ProtectedEnumClass.PublicItem1), - ProtectedEnumClass.PublicItem1) + self.assertEqual(obj.publicEnumMethod(ProtectedEnumClass.PublicEnum.PublicItem0), + ProtectedEnumClass.PublicEnum.PublicItem0) + self.assertEqual(obj.publicEnumMethod(ProtectedEnumClass.PublicEnum.PublicItem1), + ProtectedEnumClass.PublicEnum.PublicItem1) - self.assertEqual(obj.callPublicEnumMethod(ProtectedEnumClass.PublicItem0), - ProtectedEnumClass.PublicItem0) - self.assertEqual(obj.callPublicEnumMethod(ProtectedEnumClass.PublicItem1), - ProtectedEnumClass.PublicItem1) + self.assertEqual(obj.callPublicEnumMethod(ProtectedEnumClass.PublicEnum.PublicItem0), + ProtectedEnumClass.PublicEnum.PublicItem0) + self.assertEqual(obj.callPublicEnumMethod(ProtectedEnumClass.PublicEnum.PublicItem1), + ProtectedEnumClass.PublicEnum.PublicItem1) def testOverriddenProtectedMethodWithProtectedEnumArgument(self): '''Calls overridden protected method with protected enum argument.''' obj = ExtendedProtectedEnumClass() - self.assertEqual(obj.protectedEnumMethod(ProtectedEnumClass.ProtectedItem0), - ProtectedEnumClass.ProtectedItem1) - self.assertEqual(obj.protectedEnumMethod(ProtectedEnumClass.ProtectedItem1), - ProtectedEnumClass.ProtectedItem0) + self.assertEqual(obj.protectedEnumMethod(ProtectedEnumClass.ProtectedEnum.ProtectedItem0), + ProtectedEnumClass.ProtectedEnum.ProtectedItem1) + self.assertEqual(obj.protectedEnumMethod(ProtectedEnumClass.ProtectedEnum.ProtectedItem1), + ProtectedEnumClass.ProtectedEnum.ProtectedItem0) - self.assertEqual(ProtectedEnumClass.protectedEnumMethod(obj, ProtectedEnumClass.ProtectedItem0), # noqa: E501 - ProtectedEnumClass.ProtectedItem0) + self.assertEqual(ProtectedEnumClass.protectedEnumMethod(obj, ProtectedEnumClass.ProtectedEnum.ProtectedItem0), # noqa: E501 + ProtectedEnumClass.ProtectedEnum.ProtectedItem0) self.assertEqual(ProtectedEnumClass.protectedEnumMethod(obj, - ProtectedEnumClass.ProtectedItem1), ProtectedEnumClass.ProtectedItem1) + ProtectedEnumClass.ProtectedEnum.ProtectedItem1), ProtectedEnumClass.ProtectedEnum.ProtectedItem1) # noqa: E501 - self.assertEqual(obj.callProtectedEnumMethod(ProtectedEnumClass.ProtectedItem0), - ProtectedEnumClass.ProtectedItem1) - self.assertEqual(obj.callProtectedEnumMethod(ProtectedEnumClass.ProtectedItem1), - ProtectedEnumClass.ProtectedItem0) + self.assertEqual(obj.callProtectedEnumMethod(ProtectedEnumClass.ProtectedEnum.ProtectedItem0), # noqa: E501 + ProtectedEnumClass.ProtectedEnum.ProtectedItem1) + self.assertEqual(obj.callProtectedEnumMethod(ProtectedEnumClass.ProtectedEnum.ProtectedItem1), # noqa: E501 + ProtectedEnumClass.ProtectedEnum.ProtectedItem0) def testOverriddenProtectedMethodWithPublicEnumArgument(self): '''Calls overridden protected method with public enum argument.''' obj = ExtendedProtectedEnumClass() - self.assertEqual(obj.publicEnumMethod(ProtectedEnumClass.PublicItem0), - ProtectedEnumClass.PublicItem1) - self.assertEqual(obj.publicEnumMethod(ProtectedEnumClass.PublicItem1), - ProtectedEnumClass.PublicItem0) + self.assertEqual(obj.publicEnumMethod(ProtectedEnumClass.PublicEnum.PublicItem0), + ProtectedEnumClass.PublicEnum.PublicItem1) + self.assertEqual(obj.publicEnumMethod(ProtectedEnumClass.PublicEnum.PublicItem1), + ProtectedEnumClass.PublicEnum.PublicItem0) - self.assertEqual(ProtectedEnumClass.publicEnumMethod(obj, ProtectedEnumClass.PublicItem0), - ProtectedEnumClass.PublicItem0) - self.assertEqual(ProtectedEnumClass.publicEnumMethod(obj, ProtectedEnumClass.PublicItem1), - ProtectedEnumClass.PublicItem1) + self.assertEqual(ProtectedEnumClass.publicEnumMethod(obj, ProtectedEnumClass.PublicEnum.PublicItem0), # noqa: E501 + ProtectedEnumClass.PublicEnum.PublicItem0) + self.assertEqual(ProtectedEnumClass.publicEnumMethod(obj, ProtectedEnumClass.PublicEnum.PublicItem1), # noqa: E501 + ProtectedEnumClass.PublicEnum.PublicItem1) - self.assertEqual(obj.callPublicEnumMethod(ProtectedEnumClass.PublicItem0), - ProtectedEnumClass.PublicItem1) - self.assertEqual(obj.callPublicEnumMethod(ProtectedEnumClass.PublicItem1), - ProtectedEnumClass.PublicItem0) + self.assertEqual(obj.callPublicEnumMethod(ProtectedEnumClass.PublicEnum.PublicItem0), + ProtectedEnumClass.PublicEnum.PublicItem1) + self.assertEqual(obj.callPublicEnumMethod(ProtectedEnumClass.PublicEnum.PublicItem1), + ProtectedEnumClass.PublicEnum.PublicItem0) class ProtectedPropertyTest(unittest.TestCase): @@ -327,8 +328,8 @@ class ProtectedPropertyTest(unittest.TestCase): def testProtectedEnumProperty(self): '''Writes and reads a protected enum property.''' - self.obj.protectedEnumProperty = Event.SOME_EVENT - self.assertEqual(self.obj.protectedEnumProperty, Event.SOME_EVENT) + self.obj.protectedEnumProperty = Event.EventType.SOME_EVENT + self.assertEqual(self.obj.protectedEnumProperty, Event.EventType.SOME_EVENT) def testProtectedValueTypeProperty(self): '''Writes and reads a protected value type property.''' diff --git a/sources/shiboken6/tests/samplebinding/strlist_test.py b/sources/shiboken6/tests/samplebinding/strlist_test.py index d141714d3..74e3b5388 100644 --- a/sources/shiboken6/tests/samplebinding/strlist_test.py +++ b/sources/shiboken6/tests/samplebinding/strlist_test.py @@ -24,7 +24,7 @@ class StrListTest(unittest.TestCase): '''StrList constructor receives no parameter.''' sl = StrList() self.assertEqual(len(sl), 0) - self.assertEqual(sl.constructorUsed(), StrList.NoParamsCtor) + self.assertEqual(sl.constructorUsed(), StrList.CtorEnum.NoParamsCtor) def testStrListCtor_Str(self): '''StrList constructor receives a Str object.''' @@ -32,7 +32,7 @@ class StrListTest(unittest.TestCase): sl = StrList(s) self.assertEqual(len(sl), 1) self.assertEqual(sl[0], s) - self.assertEqual(sl.constructorUsed(), StrList.StrCtor) + self.assertEqual(sl.constructorUsed(), StrList.CtorEnum.StrCtor) def testStrListCtor_PythonString(self): '''StrList constructor receives a Python string.''' @@ -40,7 +40,7 @@ class StrListTest(unittest.TestCase): sl = StrList(s) self.assertEqual(len(sl), 1) self.assertEqual(sl[0], s) - self.assertEqual(sl.constructorUsed(), StrList.StrCtor) + self.assertEqual(sl.constructorUsed(), StrList.CtorEnum.StrCtor) def testStrListCtor_StrList(self): '''StrList constructor receives a StrList object.''' @@ -48,7 +48,7 @@ class StrListTest(unittest.TestCase): sl2 = StrList(sl1) #self.assertEqual(len(sl1), len(sl2)) #self.assertEqual(sl1, sl2) - self.assertEqual(sl2.constructorUsed(), StrList.CopyCtor) + self.assertEqual(sl2.constructorUsed(), StrList.CtorEnum.CopyCtor) def testStrListCtor_ListOfStrs(self): '''StrList constructor receives a Python list of Str objects.''' @@ -56,7 +56,7 @@ class StrListTest(unittest.TestCase): sl = StrList(strs) self.assertEqual(len(sl), len(strs)) self.assertEqual(sl, strs) - self.assertEqual(sl.constructorUsed(), StrList.ListOfStrCtor) + self.assertEqual(sl.constructorUsed(), StrList.CtorEnum.ListOfStrCtor) def testStrListCtor_MixedListOfStrsAndPythonStrings(self): '''StrList constructor receives a Python list of mixed Str objects and Python strings.''' @@ -64,7 +64,7 @@ class StrListTest(unittest.TestCase): sl = StrList(strs) self.assertEqual(len(sl), len(strs)) self.assertEqual(sl, strs) - self.assertEqual(sl.constructorUsed(), StrList.ListOfStrCtor) + self.assertEqual(sl.constructorUsed(), StrList.CtorEnum.ListOfStrCtor) def testCompareStrListWithTupleOfStrs(self): '''Compares StrList with a Python tuple of Str objects.''' diff --git a/sources/shiboken6/tests/samplebinding/templateinheritingclass_test.py b/sources/shiboken6/tests/samplebinding/templateinheritingclass_test.py index f16d947aa..013b9979e 100644 --- a/sources/shiboken6/tests/samplebinding/templateinheritingclass_test.py +++ b/sources/shiboken6/tests/samplebinding/templateinheritingclass_test.py @@ -20,8 +20,8 @@ from sample import Photon class TemplateInheritingClassTest(unittest.TestCase): def testClassBasics(self): - self.assertEqual(Photon.ValueIdentity.classType(), Photon.IdentityType) - self.assertEqual(Photon.ValueDuplicator.classType(), Photon.DuplicatorType) + self.assertEqual(Photon.ValueIdentity.classType(), Photon.ClassType.IdentityType) + self.assertEqual(Photon.ValueDuplicator.classType(), Photon.ClassType.DuplicatorType) def testInstanceBasics(self): value = 123 diff --git a/sources/shiboken6/tests/samplebinding/time_test.py b/sources/shiboken6/tests/samplebinding/time_test.py index 2eb2ca498..cc247ac1e 100644 --- a/sources/shiboken6/tests/samplebinding/time_test.py +++ b/sources/shiboken6/tests/samplebinding/time_test.py @@ -74,7 +74,7 @@ class TimeTest(unittest.TestCase): '''Method without parameters: Time.somethingCompletelyDifferent()''' time = Time() result = time.somethingCompletelyDifferent() - self.assertEqual(result, Time.ZeroArgs) + self.assertEqual(result, Time.NumArgs.ZeroArgs) def testMethodWithAllParamers(self): '''Method with all parameters: @@ -85,25 +85,26 @@ class TimeTest(unittest.TestCase): time = Time() obj = ObjectType() result = time.somethingCompletelyDifferent(1, 2, ImplicitConv(2), obj) - self.assertEqual(result, Time.FourArgs) + self.assertEqual(result, Time.NumArgs.FourArgs) def testMethodWithThreeParamers(self): '''Method with 3 parameters: Time.somethingCompletelyDifferent(...)''' time = Time() - result = time.somethingCompletelyDifferent(1, 2, ImplicitConv(ImplicitConv.CtorOne)) - self.assertEqual(result, Time.ThreeArgs) + result = time.somethingCompletelyDifferent(1, 2, + ImplicitConv(ImplicitConv.CtorEnum.CtorOne)) + self.assertEqual(result, Time.NumArgs.ThreeArgs) def testMethodWithTwoParamers(self): '''Method with 2 parameters: Time.somethingCompletelyDifferent(...)''' time = Time() result = time.somethingCompletelyDifferent(1, 2) - self.assertEqual(result, Time.TwoArgs) + self.assertEqual(result, Time.NumArgs.TwoArgs) def testMethodWithThreeParamersAndImplicitConversion(self): '''Method with 3 parameters, the last one triggers an implicit conversion.''' time = Time() - result = time.somethingCompletelyDifferent(1, 2, ImplicitConv.CtorOne) - self.assertEqual(result, Time.ThreeArgs) + result = time.somethingCompletelyDifferent(1, 2, ImplicitConv.CtorEnum.CtorOne) + self.assertEqual(result, Time.NumArgs.ThreeArgs) # PYSIDE-1436: These tests crash at shutdown due to `assert(Not)?Equal`. def testCompareWithPythonTime(self): |