Commit e1a41c25 authored by cdelort's avatar cdelort
Browse files

fix configuration for python3

parent 869f536b
......@@ -2,24 +2,27 @@
include(CORALConfigScripts)
function(coral_install_python_modules)
# Copy and install python modules into the build and install areas
file(GLOB _files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/python python/*.py python/*/*.py python/*/*/*.py python/*/*/*.sql)
if(NOT ${CMAKE_VERSION} VERSION_LESS 3.6.0)
list(FILTER _files EXCLUDE REGEX "#")
if (LCG_python3 STREQUAL on) # CORALCOOL-2976
# Copy and install python3 modules into the build and install areas
file(GLOB _files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/python3 python3/*.py python3/*/*.py python3/*/*/*.py python3/*/*/*.sql)
if(NOT ${CMAKE_VERSION} VERSION_LESS 3.6.0)
list(FILTER _files EXCLUDE REGEX "#")
endif()
foreach(_file ${_files})
copy_to_build(${_file} python3 python)
get_filename_component(_dstdir python/${_file} PATH)
install(FILES ${CMAKE_BINARY_DIR}/python/${_file} DESTINATION ${_dstdir})
endforeach(_file)
else()
# Copy and install python modules into the build and install areas
file(GLOB _files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/python python/*.py python/*/*.py python/*/*/*.py python/*/*/*.sql)
if(NOT ${CMAKE_VERSION} VERSION_LESS 3.6.0)
list(FILTER _files EXCLUDE REGEX "#")
endif()
foreach(_file ${_files})
copy_to_build(${_file} python python)
get_filename_component(_dstdir python/${_file} PATH)
install(FILES ${CMAKE_BINARY_DIR}/python/${_file} DESTINATION ${_dstdir})
endforeach(_file)
endif()
foreach(_file ${_files})
copy_to_build(${_file} python python)
get_filename_component(_dstdir python/${_file} PATH)
install(FILES ${CMAKE_BINARY_DIR}/python/${_file} DESTINATION ${_dstdir})
endforeach(_file)
# Copy and install python3 modules into the build and install areas
file(GLOB _files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/python3 python3/*.py python3/*/*.py python3/*/*/*.py python3/*/*/*.sql)
if(NOT ${CMAKE_VERSION} VERSION_LESS 3.6.0)
list(FILTER _files EXCLUDE REGEX "#")
endif()
foreach(_file ${_files})
copy_to_build(${_file} python3 python3)
get_filename_component(_dstdir python3/${_file} PATH)
install(FILES ${CMAKE_BINARY_DIR}/python3/${_file} DESTINATION ${_dstdir})
endforeach(_file)
endfunction()
......@@ -33,6 +33,9 @@ endfunction()
# Copy and install python tests into the build and install areas
include(CORALConfigScripts)
macro(copy_and_install_python_test _name)
copy_and_install_program(${_name} tests tests/bin tests/bin)
copy_and_install_program(${_name} tests_python3 tests_python3/bin tests_python3/bin)
if (LCG_python3 STREQUAL on) # CORALCOOL-2976
copy_and_install_program(${_name} tests_python3 tests/bin tests/bin)
else()
copy_and_install_program(${_name} tests tests/bin tests/bin)
endif()
endmacro()
......@@ -20,9 +20,9 @@ class TestAttributeList( unittest.TestCase ):
def test_010_init(self):
# Initialization
alist = coral.AttributeList()
self.assert_( not alist is None )
self.assertTrue( not alist is None )
alist = coral.AttributeList( self.alist )
self.assert_( not alist is None )
self.assertTrue( not alist is None )
#alist = coral.AttributeList( self.spec )
#self.assert_( not alist is None )
......@@ -32,34 +32,34 @@ class TestAttributeList( unittest.TestCase ):
caughtTypeError = False
try:
alist = coral.AttributeList( 'bad' )
except TypeError, e:
except TypeError as e:
caughtTypeError = True
self.assert_( caughtTypeError )
self.assertTrue( caughtTypeError )
def test_030_keys(self):
# Keys
keys = self.alist.keys()
self.assertEquals( len(keys), 4 )
self.assert_( 'i' in keys )
self.assert_( 'f' in keys )
self.assert_( 'd' in keys )
self.assert_( 's' in keys )
keys = list(self.alist.keys())
self.assertEqual( len(keys), 4 )
self.assertTrue( 'i' in keys )
self.assertTrue( 'f' in keys )
self.assertTrue( 'd' in keys )
self.assertTrue( 's' in keys )
def test_040_typeNames(self):
# Type names
types = self.alist.typeNames()
self.assertEquals( len(types), 4 )
self.assert_( 'int' in types )
self.assert_( 'float' in types )
self.assert_( 'double' in types )
self.assert_( 'string' in types )
self.assertEqual( len(types), 4 )
self.assertTrue( 'int' in types )
self.assertTrue( 'float' in types )
self.assertTrue( 'double' in types )
self.assertTrue( 'string' in types )
def test_050_typeName(self):
# Type name
self.assertEquals( self.alist.typeName( "i" ), 'int' )
self.assertEqual( self.alist.typeName( "i" ), 'int' )
def test_060_typeName_bad_key(self):
......@@ -70,7 +70,7 @@ class TestAttributeList( unittest.TestCase ):
def test_070_getitem(self):
# getitem
self.assertEquals( self.alist["i"], 0 )
self.assertEqual( self.alist["i"], 0 )
def test_080_getitem_bad_key(self):
......@@ -81,15 +81,15 @@ class TestAttributeList( unittest.TestCase ):
caughtKeyError = False
try:
self.alist['bad']
except KeyError, e:
except KeyError as e:
caughtKeyError = True
self.assert_( caughtKeyError )
self.assertTrue( caughtKeyError )
def test_090_setitem(self):
# setitem
self.alist["i"] = 5
self.assertEquals( self.alist["i"], 5 )
self.assertEqual( self.alist["i"], 5 )
def test_100_setitem_bad_key(self):
......@@ -100,54 +100,54 @@ class TestAttributeList( unittest.TestCase ):
caughtKeyError = False
try:
self.alist['bad'] = 0
except KeyError, e:
except KeyError as e:
caughtKeyError = True
self.assert_( caughtKeyError )
self.assertTrue( caughtKeyError )
def test_110_iter(self):
# default iteration
keys = self.alist.keys()
self.assertEquals( len(keys), 4 )
keys = list(self.alist.keys())
self.assertEqual( len(keys), 4 )
for key in self.alist:
self.assert_( key in keys, 'failed for key: %s' % key )
self.assertTrue( key in keys, 'failed for key: %s' % key )
keys.remove( key )
self.assertEquals( len(keys), 0 )
self.assertEqual( len(keys), 0 )
def test_120_iterkeys(self):
# iterkeys
keys = self.alist.keys()
for key in self.alist.iterkeys():
self.assert_( key in keys, 'failed for key: %s' % key )
keys = list(self.alist.keys())
for key in self.alist.keys():
self.assertTrue( key in keys, 'failed for key: %s' % key )
keys.remove( key )
self.assertEquals( len(keys), 0 )
self.assertEqual( len(keys), 0 )
def test_130_contains(self):
# contains
for key in [ 'i', 'f', 'd' ]:
self.assert_( key in self.alist, 'failed for key: %s' % key )
self.assert_( 'bad' not in self.alist )
self.assertTrue( key in self.alist, 'failed for key: %s' % key )
self.assertTrue( 'bad' not in self.alist )
def test_140_size(self):
# size and len
self.assertEquals( self.alist.size(), 4 )
self.assertEquals( len(self.alist), 4 )
self.assertEqual( self.alist.size(), 4 )
self.assertEqual( len(self.alist), 4 )
def test_150_independence(self):
# independence
a1 = coral.AttributeList()
a1.extend( "i", "int" )
a1["i"] = 1
self.assertEquals( a1["i"], 1 )
self.assertEqual( a1["i"], 1 )
a2 = coral.AttributeList()
a2.extend( "i", "int" )
a2["i"] = 2
self.assertEquals( a1["i"], 1 )
self.assertEquals( a2["i"], 2 )
self.assertEqual( a1["i"], 1 )
self.assertEqual( a2["i"], 2 )
def test_160_eq_type(self):
......@@ -162,7 +162,7 @@ class TestAttributeList( unittest.TestCase ):
self.fail()
# ROOT >= 5.23 (see bug #49690)
else:
self.assert_( a1 != 'wrong type' )
self.assertTrue( a1 != 'wrong type' )
def test_170_eq_size(self):
# Test __eq__ for different list sizes.
......@@ -171,7 +171,7 @@ class TestAttributeList( unittest.TestCase ):
a2 = coral.AttributeList()
a2.extend( "i", "int" )
a2.extend( "j", "int" )
self.assert_( a1 != a2 )
self.assertTrue( a1 != a2 )
# this test doesn't work because coral::AttributeList::operator== does not check the keys.
......@@ -181,7 +181,7 @@ class TestAttributeList( unittest.TestCase ):
a1.extend( "i", "int" )
a2 = coral.AttributeList()
a2.extend( "j", "int" )
self.assert_( a1 == a2 )
self.assertTrue( a1 == a2 )
def test_190_eq_spec_types(self):
......@@ -190,7 +190,7 @@ class TestAttributeList( unittest.TestCase ):
a1.extend( "i", "int" )
a2 = coral.AttributeList()
a2.extend( "i", "float" )
self.assert_( a1 != a2 )
self.assertTrue( a1 != a2 )
def test_200_eq_value(self):
......@@ -201,9 +201,9 @@ class TestAttributeList( unittest.TestCase ):
a2.extend( "i", "int" )
a1["i"] = 1
a2["i"] = 2
self.assert_( a1 != a2 )
self.assertTrue( a1 != a2 )
a2["i"] = 1
self.assert_( a1 == a2 )
self.assertTrue( a1 == a2 )
def test_210_ne(self):
......@@ -214,9 +214,9 @@ class TestAttributeList( unittest.TestCase ):
a2.extend( "i", "int" )
a1["i"] = 1
a2["i"] = 2
self.assert_( a1 != a2 )
self.assertTrue( a1 != a2 )
a2["i"] = 1
self.assert_( not a1 != a2 ) # NB: this is different than a1 == a2!
self.assertTrue( not a1 != a2 ) # NB: this is different than a1 == a2!
def test_220_supported_types(self):
# Tests creation of a attributes with all supported types and assigning
......@@ -243,91 +243,91 @@ class TestAttributeList( unittest.TestCase ):
# assign minimum values (where applicable) and test content
payload[ "A_BOOL" ] = False
self.assertEquals( payload["A_BOOL"], False )
self.assertEqual( payload["A_BOOL"], False )
#payload[ "A_CHAR" ] = 'a'
#self.assertEquals( payload["A_CHAR"], 'a' )
payload[ "A_UCHAR" ] = 0
self.assertEquals( payload["A_UCHAR"], '\x00' )
self.assertEqual( payload["A_UCHAR"], '\x00' )
payload[ "A_SHRT" ] = -32768 # SHRT_MIN
self.assertEquals( payload["A_SHRT"], -32768 )
self.assertEqual( payload["A_SHRT"], -32768 )
payload[ "A_USHRT" ] = 0
self.assertEquals( payload["A_USHRT"], 0 )
self.assertEqual( payload["A_USHRT"], 0 )
payload[ "A_INT" ] = -2147483648 # INT_MIN
self.assertEquals( payload["A_INT"], -2147483648 )
self.assertEqual( payload["A_INT"], -2147483648 )
payload[ "A_UINT" ] = 0
self.assertEquals( payload["A_UINT"], 0 )
self.assertEqual( payload["A_UINT"], 0 )
payload[ "A_LONGLONG" ] = -9223372036854775808 # sInt64Min
self.assertEquals( payload["A_LONGLONG"], -9223372036854775808 )
self.assertEqual( payload["A_LONGLONG"], -9223372036854775808 )
#payload[ "A_ULONGLONG" ] = 0
#self.assertEquals( payload["A_ULONGLONG"], 0 )
payload[ "A_FLOAT" ] = 0.123456789
self.assertAlmostEquals( payload["A_FLOAT"], 0.123456789, 8 )
self.assertAlmostEqual( payload["A_FLOAT"], 0.123456789, 8 )
payload[ "A_DOUBLE" ] = 0.123456789012345678901234567890
self.assertEquals( payload["A_DOUBLE"],
self.assertEqual( payload["A_DOUBLE"],
0.123456789012345678901234567890 )
payload[ "A_STRING" ] = "low values"
self.assertEquals( payload["A_STRING"], "low values" )
self.assertEqual( payload["A_STRING"], "low values" )
payload[ "A_BLOB" ].resize(10)
for i in range(10):
payload[ "A_BLOB" ][i] = 0
for i in range(10):
self.assertEquals( payload["A_BLOB"][i], 0 )
self.assertEqual( payload["A_BLOB"][i], 0 )
# assign maximum values (where applicable) and test content
payload[ "A_BOOL" ] = True
self.assertEquals( payload["A_BOOL"], True )
self.assertEqual( payload["A_BOOL"], True )
#payload[ "A_CHAR" ] = 'Z'
#self.assertEquals( payload["A_CHAR"], 'Z' )
payload[ "A_UCHAR" ] = '\xff' # = 255 UCHAR_MAX
self.assertEquals( payload["A_UCHAR"], '\xff' )
payload[ "A_UCHAR" ] = 255 # '\xff' # = 255 UCHAR_MAX
self.assertEqual( payload["A_UCHAR"], '\xff' )
payload[ "A_SHRT" ] = 32767 # SHRT_MAX
self.assertEquals( payload["A_SHRT"], 32767 )
self.assertEqual( payload["A_SHRT"], 32767 )
payload[ "A_USHRT" ] = 65535 # USHRT_MAX
self.assertEquals( payload["A_USHRT"], 65535 )
self.assertEqual( payload["A_USHRT"], 65535 )
payload[ "A_INT" ] = 2147483647 # INT_MAX
self.assertEquals( payload["A_INT"], 2147483647 )
self.assertEqual( payload["A_INT"], 2147483647 )
payload[ "A_UINT" ] = 4294967295 # UINT_MAX
self.assertEquals( payload["A_UINT"], 4294967295 )
self.assertEqual( payload["A_UINT"], 4294967295 )
payload[ "A_LONGLONG" ] = 9223372036854775807 # sInt64Max
self.assertEquals( payload["A_LONGLONG"], 9223372036854775807 )
self.assertEqual( payload["A_LONGLONG"], 9223372036854775807 )
#payload[ "A_ULONGLONG" ] = 9223372036854775807 # sInt64Max
#self.assertEquals( payload["A_ULONGLONG"], 9223372036854775807 )
payload[ "A_FLOAT" ] = 0.987654321098765432109876543210
self.assertAlmostEquals( payload["A_FLOAT"],
self.assertAlmostEqual( payload["A_FLOAT"],
0.987654321098765432109876543210, 7 )
payload[ "A_DOUBLE" ] = 0.987654321098765432109876543210
self.assertEquals( payload["A_DOUBLE"],
self.assertEqual( payload["A_DOUBLE"],
0.987654321098765432109876543210 )
payload[ "A_STRING" ] = "HIGH VALUES"
self.assertEquals( payload["A_STRING"], "HIGH VALUES" )
self.assertEqual( payload["A_STRING"], "HIGH VALUES" )
payload[ "A_BLOB" ].resize(10)
for i in range(10):
payload[ "A_BLOB" ][i] = 0xff
for i in range(10):
self.assertEquals( payload["A_BLOB"][i], 0xff )
self.assertEqual( payload["A_BLOB"][i], 0xff )
def test_230_null(self):
# Tests the python way of setting and retrieving the null attributes
# return value of a null attribute
self.alist.attribute("i").setNull(True)
self.assert_( self.alist["i"] is None )
self.assertTrue( self.alist["i"] is None )
# return value of a non-null attribute
self.alist.attribute("i").setNull(False)
self.assert_( self.alist["i"] is not None )
self.assertTrue( self.alist["i"] is not None )
# set the value to null attribute
self.alist["i"] = None
self.assert_( self.alist["i"] is None )
self.assertTrue( self.alist["i"] is None )
# set the value to non-null attribute
self.alist["i"] = 5
self.assert_( self.alist["i"] is not None )
self.assertTrue( self.alist["i"] is not None )
if __name__ == '__main__':
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment