File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -77,7 +77,7 @@ test-suite python
7777 [
7878 run ../test/exec.cpp <lib>../build/boost_python
7979 : # program args
80- : ../test/ exec.py
80+ : exec.py
8181 : # requirements
8282 $(PYTHON_PROPERTIES)
8383 <define>BOOST_PYTHON_STATIC_LIB
Original file line number Diff line number Diff line change 88
99namespace python = boost::python;
1010
11+ std::string script;
12+
1113// An abstract base class
1214class Base : public boost::noncopyable
1315{
@@ -79,12 +81,13 @@ void exec_test()
7981 std::cout << py.hello() << std::endl;
8082}
8183
84+ // void exec_file_test(std::string const &script)
8285void exec_file_test()
8386{
8487 python::object main = python::import("__main__");
8588 python::dict global(main.attr("__dict__"));
8689 global.clear();
87- python::object result = python::exec_file("exec.py" , global, global);
90+ python::object result = python::exec_file(script.c_str() , global, global);
8891 std::string global_as_string = python::extract<std::string>(python::str(global))
8992 BOOST_EXTRACT_WORKAROUND;
9093 std::cout << global_as_string << std::endl;
@@ -97,8 +100,10 @@ void exec_test_error()
97100 python::object result = python::exec("print unknown \n", global, global);
98101}
99102
100- int main()
103+ int main(int argc, char **argv )
101104{
105+ assert(argc == 2);
106+ script = argv[1];
102107 bool success = true;
103108 // Initialize the interpreter
104109 Py_Initialize();
You can’t perform that action at this time.
0 commit comments