2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-24 06:02:14 +00:00

added test for embedding tutorial

[SVN r22614]
This commit is contained in:
Joel de Guzman
2004-04-07 01:32:53 +00:00
parent bdf80a683c
commit 7d632ab3dd

View File

@@ -115,14 +115,21 @@ test_tutorial()
{
using namespace boost::python;
object main_module =
object(handle<>(borrowed(PyImport_AddModule("__main__"))));
object main_namespace = extract<dict>(
object(handle<>(borrowed(PyModule_GetDict(main_module.ptr())))));
handle<>( PyRun_String("hello = file('hello.txt', 'w')\n"
"hello.write('Hello world!')\n"
"hello.close()", Py_file_input,
main_namespace.ptr(), main_namespace.ptr()) );
object main_module(
handle<>(borrowed(PyImport_AddModule("__main__"))));
object main_namespace = main_module.attr("__dict__");
handle<>(PyRun_String(
"hello = file('hello.txt', 'w')\n"
"hello.write('Hello world!')\n"
"hello.close()"
, Py_file_input
, main_namespace.ptr()
, main_namespace.ptr())
);
}
int main()