PyUNO bridgetest: adapt to alias removals in unittest module and
fix syntax errors Change-Id: I7e853ba25fd0b541ea7d2770335810b2d9dcb207 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170399 Tested-by: Jenkins Tested-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org> Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org>
This commit is contained in:
parent
2f113fe5b2
commit
64021a1039
3 changed files with 140 additions and 140 deletions
|
@ -107,24 +107,24 @@ class TestCase( unittest.TestCase):
|
|||
self.tobj.Sequence = (self.testElement,self.testElement2)
|
||||
|
||||
def testBaseTypes(self):
|
||||
self.failUnless( 42 == self.tobj.Long , "Long attribute" )
|
||||
self.failUnless( 41 == self.tobj.ULong , "ULong attribute" )
|
||||
self.failUnless( 43 == self.tobj.Byte , "Byte attribute" )
|
||||
self.failUnless( 44 == self.tobj.UShort , "UShort attribute" )
|
||||
self.failUnless( -42 == self.tobj.Short , "Short attribute" )
|
||||
self.failUnless( 46 == self.tobj.Hyper , "Hyper attribute" )
|
||||
self.failUnless( 47 == self.tobj.UHyper , "UHyper attribute" )
|
||||
self.failUnless( self.tobj.Bool , "Bool attribute2" )
|
||||
self.failUnless( "yabadabadoo" == self.tobj.String , "String attribute" )
|
||||
self.failUnless( self.tobj.Sequence[0] == self.testElement , "Sequence test")
|
||||
self.failUnless( self.tobj.Sequence[1] == self.testElement2 , "Sequence2 test")
|
||||
self.failUnless( equalsEps( 4.3,self.tobj.Float,0.0001) , "float test" )
|
||||
self.failUnless( 4.2 == self.tobj.Double , "double test" )
|
||||
self.failUnless( self.ctx == self.tobj.Interface ,
|
||||
self.assertTrue( 42 == self.tobj.Long , "Long attribute" )
|
||||
self.assertTrue( 41 == self.tobj.ULong , "ULong attribute" )
|
||||
self.assertTrue( 43 == self.tobj.Byte , "Byte attribute" )
|
||||
self.assertTrue( 44 == self.tobj.UShort , "UShort attribute" )
|
||||
self.assertTrue( -42 == self.tobj.Short , "Short attribute" )
|
||||
self.assertTrue( 46 == self.tobj.Hyper , "Hyper attribute" )
|
||||
self.assertTrue( 47 == self.tobj.UHyper , "UHyper attribute" )
|
||||
self.assertTrue( self.tobj.Bool , "Bool attribute2" )
|
||||
self.assertTrue( "yabadabadoo" == self.tobj.String , "String attribute" )
|
||||
self.assertTrue( self.tobj.Sequence[0] == self.testElement , "Sequence test")
|
||||
self.assertTrue( self.tobj.Sequence[1] == self.testElement2 , "Sequence2 test")
|
||||
self.assertTrue( equalsEps( 4.3,self.tobj.Float,0.0001) , "float test" )
|
||||
self.assertTrue( 4.2 == self.tobj.Double , "double test" )
|
||||
self.assertTrue( self.ctx == self.tobj.Interface ,
|
||||
"object identity test with C++ object" )
|
||||
self.failUnless( not self.ctx == self.tobj , "object not identical test " )
|
||||
self.failUnless( 42 == self.tobj.transportAny( 42 ), "transportAny long" )
|
||||
self.failUnless( "woo, this is python" == self.tobj.transportAny( "woo, this is python" ), \
|
||||
self.assertTrue( not self.ctx == self.tobj , "object not identical test " )
|
||||
self.assertTrue( 42 == self.tobj.transportAny( 42 ), "transportAny long" )
|
||||
self.assertTrue( "woo, this is python" == self.tobj.transportAny( "woo, this is python" ), \
|
||||
"string roundtrip via any test" )
|
||||
|
||||
def testEnum( self ):
|
||||
|
@ -132,45 +132,45 @@ class TestCase( unittest.TestCase):
|
|||
e2 = uno.Enum( "com.sun.star.uno.TypeClass" , "LONG" )
|
||||
e3 = uno.Enum( "com.sun.star.uno.TypeClass" , "UNSIGNED_LONG" )
|
||||
e4 = uno.Enum( "test.testtools.bridgetest.TestEnum" , "TWO" )
|
||||
self.failUnless( e1 == e2 , "equal enum test" )
|
||||
self.failUnless( not (e1 == e3) , "different enums test" )
|
||||
self.failUnless( self.tobj.transportAny( e3 ) == e3, "enum roundtrip test" )
|
||||
self.assertTrue( e1 == e2 , "equal enum test" )
|
||||
self.assertTrue( not (e1 == e3) , "different enums test" )
|
||||
self.assertTrue( self.tobj.transportAny( e3 ) == e3, "enum roundtrip test" )
|
||||
self.tobj.Enum = e4
|
||||
self.failUnless( e4 == self.tobj.Enum , "enum assignment failed" )
|
||||
self.assertTrue( e4 == self.tobj.Enum , "enum assignment failed" )
|
||||
|
||||
def testType(self ):
|
||||
t1 = uno.getTypeByName( "com.sun.star.lang.XComponent" )
|
||||
t2 = uno.getTypeByName( "com.sun.star.lang.XComponent" )
|
||||
t3 = uno.getTypeByName( "com.sun.star.lang.EventObject" )
|
||||
self.failUnless( t1.typeClass == \
|
||||
self.assertTrue( t1.typeClass == \
|
||||
uno.Enum( "com.sun.star.uno.TypeClass", "INTERFACE" ), "typeclass of type test" )
|
||||
self.failUnless( t3.typeClass == \
|
||||
self.assertTrue( t3.typeClass == \
|
||||
uno.Enum( "com.sun.star.uno.TypeClass", "STRUCT" ), "typeclass of type test")
|
||||
self.failUnless( t1 == t2 , "equal type test" )
|
||||
self.failUnless( t1 == t2 , "equal type test" )
|
||||
self.failUnless( t1 == self.tobj.transportAny( t1 ), "type roundtrip test" )
|
||||
self.assertTrue( t1 == t2 , "equal type test" )
|
||||
self.assertTrue( t1 == t2 , "equal type test" )
|
||||
self.assertTrue( t1 == self.tobj.transportAny( t1 ), "type roundtrip test" )
|
||||
|
||||
def testBool( self ):
|
||||
self.failUnless( uno.Bool(1) , "uno.Bool true test" )
|
||||
self.failUnless( not uno.Bool(0) , "uno.Bool false test" )
|
||||
self.failUnless( uno.Bool( "true") , "uno.Bool true1 test" )
|
||||
self.failUnless( not uno.Bool( "false") , "uno.Bool true1 test" )
|
||||
self.assertTrue( uno.Bool(1) , "uno.Bool true test" )
|
||||
self.assertTrue( not uno.Bool(0) , "uno.Bool false test" )
|
||||
self.assertTrue( uno.Bool( "true") , "uno.Bool true1 test" )
|
||||
self.assertTrue( not uno.Bool( "false") , "uno.Bool true1 test" )
|
||||
|
||||
self.tobj.Bool = uno.Bool(1)
|
||||
self.failUnless( self.tobj.Bool , "bool true attribute test" )
|
||||
self.assertTrue( self.tobj.Bool , "bool true attribute test" )
|
||||
self.tobj.Bool = uno.Bool(0)
|
||||
self.failUnless( not self.tobj.Bool , "bool true attribute test" )
|
||||
self.assertTrue( not self.tobj.Bool , "bool true attribute test" )
|
||||
|
||||
# new boolean semantic
|
||||
self.failUnless( id( self.tobj.transportAny( True ) ) == id(True) , "boolean preserve test")
|
||||
self.failUnless( id( self.tobj.transportAny( False ) ) == id(False) , "boolean preserve test" )
|
||||
self.failUnless( id( self.tobj.transportAny(1) ) != id( True ), "boolean preserve test" )
|
||||
self.failUnless( id( self.tobj.transportAny(0) ) != id( False ), "boolean preserve test" )
|
||||
self.assertTrue( id( self.tobj.transportAny( True ) ) == id(True) , "boolean preserve test")
|
||||
self.assertTrue( id( self.tobj.transportAny( False ) ) == id(False) , "boolean preserve test" )
|
||||
self.assertTrue( id( self.tobj.transportAny(1) ) != id( True ), "boolean preserve test" )
|
||||
self.assertTrue( id( self.tobj.transportAny(0) ) != id( False ), "boolean preserve test" )
|
||||
|
||||
def testChar( self ):
|
||||
self.tobj.Char = uno.Char( u'h' )
|
||||
self.failUnless( self.tobj.Char == uno.Char( u'h' ), "char type test" )
|
||||
self.failUnless( isinstance( self.tobj.transportAny( uno.Char(u'h') ),uno.Char),"char preserve test" )
|
||||
self.assertTrue( self.tobj.Char == uno.Char( u'h' ), "char type test" )
|
||||
self.assertTrue( isinstance( self.tobj.transportAny( uno.Char(u'h') ),uno.Char),"char preserve test" )
|
||||
|
||||
def testStruct( self ):
|
||||
mystruct = uno.createUnoStruct( "test.testtools.bridgetest.TestData" )
|
||||
|
@ -178,27 +178,27 @@ class TestCase( unittest.TestCase):
|
|||
self.tobj.Struct = mystruct
|
||||
aSecondStruct = self.tobj.Struct
|
||||
|
||||
self.failUnless( self.tobj.Struct == mystruct, "struct roundtrip for equality test" )
|
||||
self.failUnless( aSecondStruct == mystruct, "struct roundtrip for equality test2" )
|
||||
self.assertTrue( self.tobj.Struct == mystruct, "struct roundtrip for equality test" )
|
||||
self.assertTrue( aSecondStruct == mystruct, "struct roundtrip for equality test2" )
|
||||
aSecondStruct.Short = 720
|
||||
self.failUnless( not aSecondStruct == mystruct , "different structs equality test" )
|
||||
self.failUnless( not self.ctx == mystruct , "object is not equal to struct test" )
|
||||
self.failUnless( mystruct == self.tobj.transportAny( mystruct ), "struct roundtrip with any test" )
|
||||
self.assertTrue( not aSecondStruct == mystruct , "different structs equality test" )
|
||||
self.assertTrue( not self.ctx == mystruct , "object is not equal to struct test" )
|
||||
self.assertTrue( mystruct == self.tobj.transportAny( mystruct ), "struct roundtrip with any test" )
|
||||
my2ndstruct = uno.createUnoStruct( "test.testtools.bridgetest.TestData", \
|
||||
1, 'h', 43, -42,44,42,41,46,47,4.3,4.2,4,"yabadabadoo",self.ctx,"yabadabadoo",())
|
||||
self.failUnless( my2ndstruct == mystruct, "struct non-default ctor test" )
|
||||
self.assertTrue( my2ndstruct == mystruct, "struct non-default ctor test" )
|
||||
def testUnicode( self ):
|
||||
uni = u'\0148'
|
||||
self.tobj.String = uni
|
||||
self.failUnless( uni == self.tobj.String )
|
||||
self.assertTrue( uni == self.tobj.String )
|
||||
|
||||
|
||||
self.tobj.String = u'dubidu'
|
||||
self.failUnless( u'dubidu' == self.tobj.String , "unicode comparison test")
|
||||
self.failUnless( 'dubidu' == self.tobj.String , "unicode vs. string comparison test" )
|
||||
self.assertTrue( u'dubidu' == self.tobj.String , "unicode comparison test")
|
||||
self.assertTrue( 'dubidu' == self.tobj.String , "unicode vs. string comparison test" )
|
||||
|
||||
def testConstant( self ):
|
||||
self.failUnless( uno.getConstantByName( "com.sun.star.beans.PropertyConcept.ATTRIBUTES" ) == 4,\
|
||||
self.assertTrue( uno.getConstantByName( "com.sun.star.beans.PropertyConcept.ATTRIBUTES" ) == 4,\
|
||||
"constant retrieval test" )
|
||||
|
||||
def testExceptions( self ):
|
||||
|
@ -208,9 +208,9 @@ class TestCase( unittest.TestCase):
|
|||
wasHere = 0
|
||||
try:
|
||||
raise ioExc( "huhuh" , self.tobj )
|
||||
except unoExc , instance:
|
||||
except unoExc:
|
||||
wasHere = 1
|
||||
self.failUnless( wasHere , "exception test 1" )
|
||||
self.assertTrue( wasHere , "exception test 1" )
|
||||
|
||||
wasHere = 0
|
||||
try:
|
||||
|
@ -218,7 +218,7 @@ class TestCase( unittest.TestCase):
|
|||
except ioExc:
|
||||
wasHere = 1
|
||||
else:
|
||||
self.failUnless( wasHere, "exception test 2" )
|
||||
self.assertTrue( wasHere, "exception test 2" )
|
||||
|
||||
wasHere = 0
|
||||
try:
|
||||
|
@ -227,27 +227,27 @@ class TestCase( unittest.TestCase):
|
|||
pass
|
||||
except unoExc:
|
||||
wasHere = 1
|
||||
self.failUnless(wasHere, "exception test 3")
|
||||
self.assertTrue(wasHere, "exception test 3")
|
||||
|
||||
illegalArg = uno.getClass( "com.sun.star.lang.IllegalArgumentException" )
|
||||
wasHere = 0
|
||||
try:
|
||||
self.tobj.raiseException( 1 , "foo" , self.tobj )
|
||||
self.failUnless( 0 , "exception test 5a" )
|
||||
self.assertTrue( 0 , "exception test 5a" )
|
||||
except ioExc:
|
||||
self.failUnless( 0 , "exception test 5b" )
|
||||
except illegalArg, i:
|
||||
self.failUnless( 1 == i.ArgumentPosition , "exception member test" )
|
||||
self.failUnless( "foo" == i.Message , "exception member test 2 " )
|
||||
self.assertTrue( 0 , "exception test 5b" )
|
||||
except illegalArg as i:
|
||||
self.assertTrue( 1 == i.ArgumentPosition , "exception member test" )
|
||||
self.assertTrue( "foo" == i.Message , "exception member test 2 " )
|
||||
wasHere = 1
|
||||
else:
|
||||
self.failUnless( 0, "except test 5c" )
|
||||
self.failUnless( wasHere, "illegal argument exception test failed" )
|
||||
self.assertTrue( 0, "except test 5c" )
|
||||
self.assertTrue( wasHere, "illegal argument exception test failed" )
|
||||
|
||||
def testInterface(self):
|
||||
clazz = uno.getClass( "com.sun.star.lang.XComponent" )
|
||||
self.failUnless( "com.sun.star.lang.XComponent" == clazz.__pyunointerface__ )
|
||||
self.failUnless( issubclass( clazz, uno.getClass( "com.sun.star.uno.XInterface" ) ) )
|
||||
self.assertTrue( "com.sun.star.lang.XComponent" == clazz.__pyunointerface__ )
|
||||
self.assertTrue( issubclass( clazz, uno.getClass( "com.sun.star.uno.XInterface" ) ) )
|
||||
self.tobj.Interface = None
|
||||
|
||||
|
||||
|
@ -257,48 +257,48 @@ class TestCase( unittest.TestCase):
|
|||
mydouble,myenum,mystring,myinterface,myany,myseq,my2ndstruct = self.tobj.getValues( \
|
||||
None,None,None,None,None,None,None,None,None,None, \
|
||||
None,None,None,None,None,None,None)
|
||||
self.failUnless(struct == self.tobj.Struct, "outparam 1 test")
|
||||
self.failUnless(self.tobj.Bool, "outparam 2 test")
|
||||
self.failUnless(mychar == self.tobj.Char, "outparam 3 test")
|
||||
self.failUnless(mybyte == self.tobj.Byte, "outparam 4 test")
|
||||
self.failUnless(myshort == self.tobj.Short, "outparam 5 test")
|
||||
self.failUnless(myushort == self.tobj.UShort, "outparam 6 test")
|
||||
self.failUnless(mylong == self.tobj.Long, "outparam 7 test")
|
||||
self.failUnless(myulong == self.tobj.ULong, "outparam 8 test")
|
||||
self.failUnless(myhyper == self.tobj.Hyper, "outparam 9 test")
|
||||
self.failUnless(myuhyper == self.tobj.UHyper, "outparam 10 test")
|
||||
self.failUnless(myfloat == self.tobj.Float, "outparam 11 test")
|
||||
self.failUnless(mydouble == self.tobj.Double, "outparam 12 test")
|
||||
self.failUnless(myenum == self.tobj.Enum, "outparam 13 test")
|
||||
self.failUnless(mystring == self.tobj.String, "outparam 14 test")
|
||||
self.failUnless(myinterface == self.tobj.Interface, "outparam 15 test")
|
||||
self.failUnless(myany == self.tobj.Any, "outparam 16 test")
|
||||
self.failUnless(myseq == self.tobj.Sequence, "outparam 17 test")
|
||||
self.failUnless(my2ndstruct == struct, "outparam 18 test")
|
||||
self.assertTrue(struct == self.tobj.Struct, "outparam 1 test")
|
||||
self.assertTrue(self.tobj.Bool, "outparam 2 test")
|
||||
self.assertTrue(mychar == self.tobj.Char, "outparam 3 test")
|
||||
self.assertTrue(mybyte == self.tobj.Byte, "outparam 4 test")
|
||||
self.assertTrue(myshort == self.tobj.Short, "outparam 5 test")
|
||||
self.assertTrue(myushort == self.tobj.UShort, "outparam 6 test")
|
||||
self.assertTrue(mylong == self.tobj.Long, "outparam 7 test")
|
||||
self.assertTrue(myulong == self.tobj.ULong, "outparam 8 test")
|
||||
self.assertTrue(myhyper == self.tobj.Hyper, "outparam 9 test")
|
||||
self.assertTrue(myuhyper == self.tobj.UHyper, "outparam 10 test")
|
||||
self.assertTrue(myfloat == self.tobj.Float, "outparam 11 test")
|
||||
self.assertTrue(mydouble == self.tobj.Double, "outparam 12 test")
|
||||
self.assertTrue(myenum == self.tobj.Enum, "outparam 13 test")
|
||||
self.assertTrue(mystring == self.tobj.String, "outparam 14 test")
|
||||
self.assertTrue(myinterface == self.tobj.Interface, "outparam 15 test")
|
||||
self.assertTrue(myany == self.tobj.Any, "outparam 16 test")
|
||||
self.assertTrue(myseq == self.tobj.Sequence, "outparam 17 test")
|
||||
self.assertTrue(my2ndstruct == struct, "outparam 18 test")
|
||||
|
||||
# should work, debug on windows, why not
|
||||
# struct, mybool,mychar,mybyte,myshort,myushort,mylong,myulong,myhyper,myuhyper,myfloat,\
|
||||
# mydouble,myenum,mystring,myinterface,myany,myseq,my2ndstruct = self.tobj.setValues2( \
|
||||
# mybool,mychar,mybyte,myshort,myushort,mylong,myulong,myhyper,myuhyper,myfloat,\
|
||||
# mydouble,myenum,mystring,myinterface,myany,myseq,my2ndstruct)
|
||||
# self.failUnless(struct == self.tobj.Struct, "outparam 1 test")
|
||||
# self.failUnless( mybool and self.tobj.Bool, "outparam 2 test")
|
||||
# self.failUnless(mychar == self.tobj.Char, "outparam 3 test")
|
||||
# self.failUnless(mybyte == self.tobj.Byte, "outparam 4 test")
|
||||
# self.failUnless(myshort == self.tobj.Short, "outparam 5 test")
|
||||
# self.failUnless(myushort == self.tobj.UShort, "outparam 6 test")
|
||||
# self.failUnless(mylong == self.tobj.Long, "outparam 7 test")
|
||||
# self.failUnless(myulong == self.tobj.ULong, "outparam 8 test")
|
||||
# self.failUnless(myhyper == self.tobj.Hyper, "outparam 9 test")
|
||||
# self.failUnless(myuhyper == self.tobj.UHyper, "outparam 10 test")
|
||||
# self.failUnless(myfloat == self.tobj.Float, "outparam 11 test")
|
||||
# self.failUnless(mydouble == self.tobj.Double, "outparam 12 test")
|
||||
# self.failUnless(myenum == self.tobj.Enum, "outparam 13 test")
|
||||
# self.failUnless(mystring == self.tobj.String, "outparam 14 test")
|
||||
# self.failUnless(myinterface == self.tobj.Interface, "outparam 15 test")
|
||||
# self.failUnless(myany == self.tobj.Any, "outparam 16 test")
|
||||
# self.failUnless(myseq == self.tobj.Sequence, "outparam 17 test")
|
||||
# self.failUnless(my2ndstruct == struct, "outparam 18 test")
|
||||
# self.assertTrue(struct == self.tobj.Struct, "outparam 1 test")
|
||||
# self.assertTrue( mybool and self.tobj.Bool, "outparam 2 test")
|
||||
# self.assertTrue(mychar == self.tobj.Char, "outparam 3 test")
|
||||
# self.assertTrue(mybyte == self.tobj.Byte, "outparam 4 test")
|
||||
# self.assertTrue(myshort == self.tobj.Short, "outparam 5 test")
|
||||
# self.assertTrue(myushort == self.tobj.UShort, "outparam 6 test")
|
||||
# self.assertTrue(mylong == self.tobj.Long, "outparam 7 test")
|
||||
# self.assertTrue(myulong == self.tobj.ULong, "outparam 8 test")
|
||||
# self.assertTrue(myhyper == self.tobj.Hyper, "outparam 9 test")
|
||||
# self.assertTrue(myuhyper == self.tobj.UHyper, "outparam 10 test")
|
||||
# self.assertTrue(myfloat == self.tobj.Float, "outparam 11 test")
|
||||
# self.assertTrue(mydouble == self.tobj.Double, "outparam 12 test")
|
||||
# self.assertTrue(myenum == self.tobj.Enum, "outparam 13 test")
|
||||
# self.assertTrue(mystring == self.tobj.String, "outparam 14 test")
|
||||
# self.assertTrue(myinterface == self.tobj.Interface, "outparam 15 test")
|
||||
# self.assertTrue(myany == self.tobj.Any, "outparam 16 test")
|
||||
# self.assertTrue(myseq == self.tobj.Sequence, "outparam 17 test")
|
||||
# self.assertTrue(my2ndstruct == struct, "outparam 18 test")
|
||||
|
||||
def testErrors( self ):
|
||||
|
||||
|
@ -310,45 +310,45 @@ class TestCase( unittest.TestCase):
|
|||
wasHere = 1
|
||||
except IllegalArgumentException:
|
||||
wasHere = 1
|
||||
self.failUnless( wasHere, "wrong attribute test" )
|
||||
self.assertTrue( wasHere, "wrong attribute test" )
|
||||
|
||||
IllegalArgumentException = uno.getClass("com.sun.star.lang.IllegalArgumentException" )
|
||||
RuntimeException = uno.getClass("com.sun.star.uno.RuntimeException" )
|
||||
|
||||
# TODO: Remove this once it is done
|
||||
# wrong number of arguments bug !?
|
||||
self.failUnlessRaises( IllegalArgumentException, self.tobj.transportAny, 42, 43 )
|
||||
self.failUnlessRaises( IllegalArgumentException, self.tobj.transportAny )
|
||||
self.failUnlessRaises( RuntimeException, uno.getClass, "a.b" )
|
||||
self.failUnlessRaises( RuntimeException, uno.getClass, "com.sun.star.uno.TypeClass" )
|
||||
self.assertRaises( IllegalArgumentException, self.tobj.transportAny, 42, 43 )
|
||||
self.assertRaises( IllegalArgumentException, self.tobj.transportAny )
|
||||
self.assertRaises( RuntimeException, uno.getClass, "a.b" )
|
||||
self.assertRaises( RuntimeException, uno.getClass, "com.sun.star.uno.TypeClass" )
|
||||
|
||||
self.failUnlessRaises( RuntimeException, uno.Enum, "a" , "b" )
|
||||
self.failUnlessRaises( RuntimeException, uno.Enum, "com.sun.star.uno.TypeClass" , "b" )
|
||||
self.failUnlessRaises( RuntimeException, uno.Enum, "com.sun.star.uno.XInterface" , "b" )
|
||||
self.assertRaises( RuntimeException, uno.Enum, "a" , "b" )
|
||||
self.assertRaises( RuntimeException, uno.Enum, "com.sun.star.uno.TypeClass" , "b" )
|
||||
self.assertRaises( RuntimeException, uno.Enum, "com.sun.star.uno.XInterface" , "b" )
|
||||
|
||||
tcInterface =uno.Enum( "com.sun.star.uno.TypeClass" , "INTERFACE" )
|
||||
self.failUnlessRaises( RuntimeException, uno.Type, "a", tcInterface )
|
||||
self.failUnlessRaises( RuntimeException, uno.Type, "com.sun.star.uno.Exception", tcInterface )
|
||||
self.assertRaises( RuntimeException, uno.Type, "a", tcInterface )
|
||||
self.assertRaises( RuntimeException, uno.Type, "com.sun.star.uno.Exception", tcInterface )
|
||||
|
||||
self.failUnlessRaises( (RuntimeException,exceptions.RuntimeError), uno.getTypeByName, "a" )
|
||||
self.assertRaises( (RuntimeException,exceptions.RuntimeError), uno.getTypeByName, "a" )
|
||||
|
||||
self.failUnlessRaises( (RuntimeException), uno.getConstantByName, "a" )
|
||||
self.failUnlessRaises( (RuntimeException), uno.getConstantByName, "com.sun.star.uno.XInterface" )
|
||||
self.assertRaises( (RuntimeException), uno.getConstantByName, "a" )
|
||||
self.assertRaises( (RuntimeException), uno.getConstantByName, "com.sun.star.uno.XInterface" )
|
||||
|
||||
def testByteSequence( self ):
|
||||
s = uno.ByteSequence( b"ab" )
|
||||
self.failUnless( s == uno.ByteSequence( b"ab" ) )
|
||||
self.failUnless( uno.ByteSequence( b"abc" ) == s + uno.ByteSequence( b"c" ) )
|
||||
self.failUnless( uno.ByteSequence( b"abc" ) == s + "c" )
|
||||
self.failUnless( s + "c" == "abc" )
|
||||
self.failUnless( s == uno.ByteSequence( s ) )
|
||||
self.failUnless( s[0] == 'a' )
|
||||
self.failUnless( s[1] == 'b' )
|
||||
self.assertTrue( s == uno.ByteSequence( b"ab" ) )
|
||||
self.assertTrue( uno.ByteSequence( b"abc" ) == s + uno.ByteSequence( b"c" ) )
|
||||
self.assertTrue( uno.ByteSequence( b"abc" ) == s + "c" )
|
||||
self.assertTrue( s + "c" == "abc" )
|
||||
self.assertTrue( s == uno.ByteSequence( s ) )
|
||||
self.assertTrue( s[0] == 'a' )
|
||||
self.assertTrue( s[1] == 'b' )
|
||||
|
||||
|
||||
def testInvoke( self ):
|
||||
self.failUnless( 5 == uno.invoke( self.tobj , "transportAny" , (uno.Any("byte", 5),) ) )
|
||||
self.failUnless( 5 == uno.invoke(
|
||||
self.assertTrue( 5 == uno.invoke( self.tobj , "transportAny" , (uno.Any("byte", 5),) ) )
|
||||
self.assertTrue( 5 == uno.invoke(
|
||||
PythonTransporter(), "transportAny" , (uno.Any( "byte", 5 ),) ) )
|
||||
t = uno.getTypeByName( "long" )
|
||||
mystruct = uno.createUnoStruct(
|
||||
|
|
|
@ -105,9 +105,9 @@ class TestCase(unittest.TestCase):
|
|||
|
||||
dataInput.setInputStream( SequenceInputStream2( streamOut.getSequence() ) )
|
||||
|
||||
self.failUnless( 42 == dataInput.readShort() )
|
||||
self.failUnless( 43 == dataInput.readLong() )
|
||||
self.failUnless( self.tobj.transportAny( streamOut ) == streamOut )
|
||||
self.assertTrue( 42 == dataInput.readShort() )
|
||||
self.assertTrue( 43 == dataInput.readLong() )
|
||||
self.assertTrue( self.tobj.transportAny( streamOut ) == streamOut )
|
||||
|
||||
|
||||
class NullDevice:
|
||||
|
@ -130,14 +130,14 @@ class TestHelperCase( unittest.TestCase ):
|
|||
def testUrlHelper( self ):
|
||||
systemPath = os.getcwd()
|
||||
if systemPath.startswith( "/" ):
|
||||
self.failUnless( "/tmp" == unohelper.fileUrlToSystemPath( "file:///tmp" ) )
|
||||
self.failUnless( "file:///tmp" == unohelper.systemPathToFileUrl( "/tmp" ))
|
||||
self.assertTrue( "/tmp" == unohelper.fileUrlToSystemPath( "file:///tmp" ) )
|
||||
self.assertTrue( "file:///tmp" == unohelper.systemPathToFileUrl( "/tmp" ))
|
||||
else:
|
||||
self.failUnless( "c:\\temp" == unohelper.fileUrlToSystemPath( "file:///c:/temp" ) )
|
||||
self.failUnless( "file:///c:/temp" == unohelper.systemPathToFileUrl( "c:\\temp" ) )
|
||||
self.assertTrue( "c:\\temp" == unohelper.fileUrlToSystemPath( "file:///c:/temp" ) )
|
||||
self.assertTrue( "file:///c:/temp" == unohelper.systemPathToFileUrl( "c:\\temp" ) )
|
||||
|
||||
systemPath = unohelper.systemPathToFileUrl( systemPath )
|
||||
self.failUnless( systemPath + "/a" == unohelper.absolutize( systemPath, "a" ) )
|
||||
self.assertTrue( systemPath + "/a" == unohelper.absolutize( systemPath, "a" ) )
|
||||
def testInspect( self ):
|
||||
dev = NullDevice()
|
||||
# dev = sys.stdout
|
||||
|
@ -153,7 +153,7 @@ class TestHelperCase( unittest.TestCase ):
|
|||
listener = EventListener()
|
||||
smgr.addEventListener( listener )
|
||||
smgr.dispose()
|
||||
self.failUnless( listener.disposingCalled )
|
||||
self.assertTrue( listener.disposingCalled )
|
||||
|
||||
# check, whether listeners can be removed
|
||||
smgr = uno.getComponentContext().ServiceManager.createInstance(
|
||||
|
@ -162,15 +162,15 @@ class TestHelperCase( unittest.TestCase ):
|
|||
smgr.addEventListener( listener )
|
||||
smgr.removeEventListener( listener )
|
||||
smgr.dispose()
|
||||
self.failUnless( not listener.disposingCalled )
|
||||
self.assertTrue( not listener.disposingCalled )
|
||||
|
||||
def testCurrentContext( self ):
|
||||
oldContext = uno.getCurrentContext()
|
||||
try:
|
||||
uno.setCurrentContext(
|
||||
unohelper.CurrentContext( oldContext,{"My42":42}) )
|
||||
self.failUnless( 42 == uno.getCurrentContext().getValueByName( "My42" ) )
|
||||
self.failUnless( None == uno.getCurrentContext().getValueByName( "My43" ) )
|
||||
self.assertTrue( 42 == uno.getCurrentContext().getValueByName( "My42" ) )
|
||||
self.assertTrue( None == uno.getCurrentContext().getValueByName( "My43" ) )
|
||||
finally:
|
||||
uno.setCurrentContext( oldContext )
|
||||
|
||||
|
|
|
@ -32,12 +32,12 @@ class ImporterTestCase(unittest.TestCase):
|
|||
"com.sun.star.test.bridge.CppTestObject",self.ctx)
|
||||
|
||||
def testStandard( self ):
|
||||
self.failUnless( IllegalArgumentException != None, "none-test" )
|
||||
self.failUnlessRaises( IllegalArgumentException, self.tobj.raiseException, 1,"foo",self.tobj)
|
||||
self.assertTrue( IllegalArgumentException != None, "none-test" )
|
||||
self.assertRaises( IllegalArgumentException, self.tobj.raiseException, 1,"foo",self.tobj)
|
||||
|
||||
self.failUnless( TWO == uno.Enum( "test.testtools.bridgetest.TestEnum","TWO"), "enum" )
|
||||
self.failUnless( UNSIGNED_LONG == uno.Enum( "com.sun.star.uno.TypeClass", "UNSIGNED_LONG" ) )
|
||||
self.failUnless( typeOfIllegalArgumentException ==
|
||||
self.assertTrue( TWO == uno.Enum( "test.testtools.bridgetest.TestEnum","TWO"), "enum" )
|
||||
self.assertTrue( UNSIGNED_LONG == uno.Enum( "com.sun.star.uno.TypeClass", "UNSIGNED_LONG" ) )
|
||||
self.assertTrue( typeOfIllegalArgumentException ==
|
||||
uno.Type( "com.sun.star.lang.IllegalArgumentException", EXCEPTION) )
|
||||
|
||||
# should not throw an exception
|
||||
|
@ -48,17 +48,17 @@ class ImporterTestCase(unittest.TestCase):
|
|||
|
||||
def testDynamicComponentRegistration( self ):
|
||||
ctx = uno.getComponentContext()
|
||||
self.failUnless(
|
||||
self.assertTrue(
|
||||
not ("com.sun.star.connection.Acceptor" in ctx.ServiceManager.getAvailableServiceNames()),
|
||||
"precondition for dynamic component registration test is not fulfilled" )
|
||||
self.failUnless(
|
||||
self.assertTrue(
|
||||
not ("com.sun.star.connection.Connector" in ctx.ServiceManager.getAvailableServiceNames()),
|
||||
"precondition for dynamic component registration test is not fulfilled" )
|
||||
unohelper.addComponentsToContext(
|
||||
ctx , ctx, ("acceptor.uno","connector.uno"), "com.sun.star.loader.SharedLibrary" )
|
||||
self.failUnless(
|
||||
self.assertTrue(
|
||||
("com.sun.star.connection.Acceptor" in ctx.ServiceManager.getAvailableServiceNames()) )
|
||||
self.failUnless(
|
||||
self.assertTrue(
|
||||
("com.sun.star.connection.Connector" in ctx.ServiceManager.getAvailableServiceNames()))
|
||||
|
||||
def suite( ctx ):
|
||||
|
|
Loading…
Reference in a new issue