From 7f3bb0b66ce4f644eaf21d008805fa5a6a778483 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Thu, 19 Aug 2021 12:09:19 +0200 Subject: [PATCH] WIP --- src/Container/SALOME_CPythonHelper.cxx | 8 +++--- src/SALOMESDS/TestSalomeSDS.py | 34 ++++++++++++-------------- 2 files changed, 19 insertions(+), 23 deletions(-) diff --git a/src/Container/SALOME_CPythonHelper.cxx b/src/Container/SALOME_CPythonHelper.cxx index c0741d1f7..e536fe205 100644 --- a/src/Container/SALOME_CPythonHelper.cxx +++ b/src/Container/SALOME_CPythonHelper.cxx @@ -120,13 +120,13 @@ std::string SALOME_CPythonHelper::evalS(const std::string& pyCode) const return ret; } + SALOME_CPythonHelper::~SALOME_CPythonHelper() { // _globals is borrowed ref -> do nothing - /*if(_locals) - { - auto refcount_locals = Py_REFCNT(_locals); - }*/ + + /*if(_locals){ auto refcount_locals = Py_REFCNT(_locals); }*/ + Py_XDECREF(_locals); Py_XDECREF(_pickler); } diff --git a/src/SALOMESDS/TestSalomeSDS.py b/src/SALOMESDS/TestSalomeSDS.py index 0a6cf90a0..2c4c27dc3 100644 --- a/src/SALOMESDS/TestSalomeSDS.py +++ b/src/SALOMESDS/TestSalomeSDS.py @@ -95,7 +95,7 @@ def func_test7(scopeName,cv,cv2,cv3,sharedNum): class SalomeSDSTest(unittest.TestCase): - def tessList1(self): + def testList1(self): scopeName = "Scope0" a=SalomeSDSClt.CreateRdExtGlobalVar([],"a",scopeName) self.assertEqual(a.local_copy(),[]) @@ -119,7 +119,7 @@ class SalomeSDSTest(unittest.TestCase): salome.dsm.removeDataScope(scopeName) pass - def tessDict1(self): + def testDict1(self): scopeName = "Scope0" a=SalomeSDSClt.CreateRdExtGlobalVar({},"a",scopeName) a["ab"]=4 @@ -145,7 +145,7 @@ class SalomeSDSTest(unittest.TestCase): salome.dsm.removeDataScope(scopeName) pass - def tessReadOnly1(self): + def testReadOnly1(self): scopeName = "Scope0" # a=SalomeSDSClt.CreateRdOnlyGlobalVar({"ab":4,"cd":[5,77]},"a",scopeName) @@ -189,7 +189,7 @@ class SalomeSDSTest(unittest.TestCase): self.assertEqual(asyncResult.get(),nbProc*[0]) # <- the big test is here ! dsm.removeDataScope(scopeName) - def tessTransaction2(self): + def testTransaction2(self): scopeName="Scope1" varName="a" dsm=salome.naming_service.Resolve("/DataServerManager") @@ -214,7 +214,7 @@ class SalomeSDSTest(unittest.TestCase): self.assertEqual(str2Obj(dss.waitForMonoThrRev(wk)),[7,8,9,10]) dsm.removeDataScope(scopeName) - def tessTransaction3(self): + def testTransaction3(self): scopeName="Scope1" varName="a" dsm=salome.naming_service.Resolve("/DataServerManager") @@ -237,7 +237,7 @@ class SalomeSDSTest(unittest.TestCase): self.assertEqual(str2Obj(dss.fetchSerializedContent(varName)),{'cd':[7,8,9,10]}) dsm.removeDataScope(scopeName) - def tessTransaction4(self): + def testTransaction4(self): scopeName="Scope1" varName="a" dsm=salome.naming_service.Resolve("/DataServerManager") @@ -262,7 +262,7 @@ class SalomeSDSTest(unittest.TestCase): self.assertEqual(str2Obj(dss.fetchSerializedContent(varName)),{'ab':[4,5,6]}) dsm.removeDataScope(scopeName) - def tessTransaction5(self): + def testTransaction5(self): """ Like testTransaction2 but without transactions. """ scopeName="Scope1" varName="a" @@ -297,7 +297,7 @@ class SalomeSDSTest(unittest.TestCase): self.assertEqual(set(keys),set(['ab','cd'])) dsm.removeDataScope(scopeName) - def tessTransaction6(self): + def testTransaction6(self): """ Test to test RdWr global vars with transaction""" scopeName="Scope1" varName="a" @@ -346,7 +346,7 @@ class SalomeSDSTest(unittest.TestCase): dsm.removeDataScope(scopeName) pass - def tessTransaction7(self): + def testTransaction7(self): """Like testTransaction5 but after a recovery.""" scopeName="Scope1" varName="a" @@ -371,7 +371,7 @@ class SalomeSDSTest(unittest.TestCase): dsm.removeDataScope(scopeName) pass - def tessTransaction8(self): + def testTransaction8(self): """ EDF 16833 and EDF17719 """ funcContent="""def comptchev(a,b): return "d" not in a @@ -409,7 +409,7 @@ class SalomeSDSTest(unittest.TestCase): dsm.removeDataScope(scopeName) pass - def tessTransaction9(self): + def testTransaction9(self): """ EDF 16833 and EDF17719 : use case 2. Trying to createRdExt during add key session""" funcContent="""def comptchev(a,b): return a==b @@ -440,7 +440,7 @@ class SalomeSDSTest(unittest.TestCase): pass - def tessLockToDump(self): + def testLockToDump(self): """ Test to check that holdRequests method. This method wait for clean server status and hold it until activeRequests is called. Warning this method expects a not overloaded machine to be run because test is based on ellapse time. """ @@ -493,15 +493,11 @@ class SalomeSDSTest(unittest.TestCase): p.join() dsm.removeDataScope(scopeName) pass - - def setUp(self): - salome.salome_init_without_session() - pass pass if __name__=="__main__": - unittest.main() - salome.salome_close() - + with salome.SessionContextManager(): + unittest.main() + -- 2.39.2