Salome HOME
venv directory is configured in config_appli.xml file
[modules/kernel.git] / src / KERNEL_PY / kernel / testdata.py
index aff6f930119f6e3f11f57089ec1080d4233c2f33..b469dcb55ef895b52bf19645ae23ba7bbe844bec 100644 (file)
@@ -1,5 +1,5 @@
 # -*- coding: iso-8859-1 -*-
-# Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
+# Copyright (C) 2007-2021  CEA/DEN, EDF R&D, OPEN CASCADE
 #
 # Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -7,7 +7,7 @@
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
 # License as published by the Free Software Foundation; either
-# version 2.1 of the License.
+# version 2.1 of the License, or (at your option) any later version.
 #
 # This library is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -24,8 +24,8 @@
 __author__="gboulant"
 __date__ ="$17 avr. 2010 19:44:36$"
 
-from enumerate import Enumerate
-from datamodeler import DataModeler, TypeString, TypeInteger
+from .enumerate import Enumerate
+from .datamodeler import DataModeler, TypeString, TypeInteger
 from salome.kernel import Callable
 
 class TestData(DataModeler):
@@ -79,7 +79,7 @@ class TestData(DataModeler):
 # Basic use cases and unit tests
 # ==============================================================================
 #
-from uiexception import UiException
+from .uiexception import UiException
 
 def TEST_getName():
     testdata = TestData()
@@ -96,8 +96,8 @@ def TEST_useBadKey():
         testdata.unknown = "unknown"
         # This should not arrive here
         return False
-    except UiException, err:
-        print err
+    except UiException as err:
+        print(err)
         return True
 
 def TEST_useBadType():
@@ -106,8 +106,8 @@ def TEST_useBadType():
         testdata.TYPE = "unknown"
         # This should not arrive here
         return False
-    except UiException, err:
-        print err
+    except UiException as err:
+        print(err)
         return True
 
 def TEST_useBadRange():
@@ -117,26 +117,26 @@ def TEST_useBadRange():
         testdata.TYPE = TestData.TYPES_LIST.SEP
         testdata.setType(TestData.TYPES_LIST.SEP)
         # This should arrive here
-    except UiException, err:
+    except UiException as err:
         # And not here
-        print err
+        print(err)
         return False
 
     try:
         testdata.TYPE = 9999 # a type that does not exist in the range
         # This should not arrive here
         return False
-    except UiException, err:
-        print err
+    except UiException as err:
+        print(err)
         return True
 
 def TEST_serialize():
     import salome.kernel
     ref_testdata = TestData()
-    ref_testdata.setName("The firts name")
+    ref_testdata.setName("The first name")
     res_testdata = salome.kernel.unserialize(salome.kernel.serialize(ref_testdata))
 
-    print res_testdata.getName()
+    print(res_testdata.getName())
 
     if res_testdata.getName() != ref_testdata.getName():
         return False
@@ -144,14 +144,14 @@ def TEST_serialize():
     # Is the unserialized data still functional?
     try:
         res_testdata.setName("An other name")
-        print res_testdata.getName()
-    except:
-        print e
+        print(res_testdata.getName())
+    except Exception:
+        print(e)
         return False
     return True
 
 if __name__ == "__main__":
-    from unittester import run
+    from .unittester import run
     run("salome/kernel/testdata","TEST_getName")
     run("salome/kernel/testdata","TEST_useBadKey")
     run("salome/kernel/testdata","TEST_useBadType")