X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2Fpy2yacs%2FTest%2FPy2yacsTest.cxx;h=ffd74f9f1d6b4f02ad927ffa2bd47783474a71cc;hb=cc51b9ff75f0e73d5424e421b2c698798177c8cc;hp=2f431a331b1c80a932dc45ab1bfede6c5fe5a33f;hpb=fd4934f49ee2770cd881b0f25a4bb00b12183b68;p=modules%2Fyacs.git diff --git a/src/py2yacs/Test/Py2yacsTest.cxx b/src/py2yacs/Test/Py2yacsTest.cxx index 2f431a331..ffd74f9f1 100644 --- a/src/py2yacs/Test/Py2yacsTest.cxx +++ b/src/py2yacs/Test/Py2yacsTest.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2006-2020 CEA/DEN, EDF R&D +// Copyright (C) 2006-2023 CEA, EDF // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -25,6 +25,7 @@ #include "py2yacs.hxx" #include "Proc.hxx" #include "Executor.hxx" +#include "PythonCppUtils.hxx" #include "RuntimeSALOME.hxx" #include "PythonPorts.hxx" @@ -220,6 +221,7 @@ void Py2yacsTest::unaccepted_statement() verifyWrongPycode(code_py, "f", "not accepted statement"); } +/* // This is now accepted void Py2yacsTest::unaccepted_statement2() { const char * code_py = "def f(a):\n" @@ -227,7 +229,7 @@ void Py2yacsTest::unaccepted_statement2() "if __name__ == '__main__':" " print('toto')\n"; verifyWrongPycode(code_py, "f", "not accepted statement"); -} +}*/ void Py2yacsTest::unaccepted_return() { @@ -294,10 +296,16 @@ void Py2yacsTest::schemaExec() // verify the output port value YACS::ENGINE::OutputPyPort* var = dynamic_cast(n->getOutputPort("x")); CPPUNIT_ASSERT(var); + double x = -2.0; PyObject* pyVal = var->get(); - CPPUNIT_ASSERT(pyVal); - CPPUNIT_ASSERT(PyFloat_Check(pyVal)); - CPPUNIT_ASSERT_DOUBLES_EQUAL(42., PyFloat_AsDouble(pyVal), 1.E-12); + { + AutoGIL agil; + CPPUNIT_ASSERT(pyVal); + x = PyFloat_AsDouble(pyVal); + CPPUNIT_ASSERT( PyErr_Occurred()==nullptr );// check pyVal is interpretable as float + } + CPPUNIT_ASSERT_DOUBLES_EQUAL(42., x, 1.E-12); + p->shutdown(10); // kill all the containers } // Test the behaviour when there is an error in the python parser