Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r55640 - trunk/libs/python/test
From: rwgk_at_[hidden]
Date: 2009-08-17 20:49:06


Author: rwgk
Date: 2009-08-17 20:49:05 EDT (Mon, 17 Aug 2009)
New Revision: 55640
URL: http://svn.boost.org/trac/boost/changeset/55640

Log:
libs/python/test/exec.cpp: new exercise_embedding_html(), in reaction to https://svn.boost.org/trac/boost/ticket/1890
Text files modified:
   trunk/libs/python/test/exec.cpp | 26 ++++++++++++++++++++++++--
   1 files changed, 24 insertions(+), 2 deletions(-)

Modified: trunk/libs/python/test/exec.cpp
==============================================================================
--- trunk/libs/python/test/exec.cpp (original)
+++ trunk/libs/python/test/exec.cpp 2009-08-17 20:49:05 EDT (Mon, 17 Aug 2009)
@@ -108,6 +108,21 @@
   python::object result = python::exec("print unknown \n", global, global);
 }
 
+void exercise_embedding_html()
+{
+ using namespace boost::python;
+ /* code from: libs/python/doc/tutorial/doc/tutorial.qbk
+ (generates libs/python/doc/tutorial/doc/html/python/embedding.html)
+ */
+ object main_module = import("__main__");
+ object main_namespace = main_module.attr("__dict__");
+
+ object ignored = exec("hello = file('hello.txt', 'w')\n"
+ "hello.write('Hello world!')\n"
+ "hello.close()",
+ main_namespace);
+}
+
 void check_pyerr(bool pyerr_expected=false)
 {
   if (PyErr_Occurred())
@@ -129,7 +144,7 @@
 
 int main(int argc, char **argv)
 {
- BOOST_TEST(argc == 2);
+ BOOST_TEST(argc == 2 || argc == 3);
   std::string script = argv[1];
   // Initialize the interpreter
   Py_Initialize();
@@ -152,7 +167,14 @@
   {
     BOOST_ERROR("Python exception expected, but not seen.");
   }
-
+
+ if (argc > 2) {
+ // The main purpose is to test compilation. Since this test generates
+ // a file and I (rwgk) am uncertain about the side-effects, run it only
+ // if explicitly requested.
+ exercise_embedding_html();
+ }
+
   // Boost.Python doesn't support Py_Finalize yet.
   // Py_Finalize();
   return boost::report_errors();


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk