File tree 1 file changed +16
-0
lines changed
1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -197,6 +197,22 @@ TEST_CASE("Custom PyConfig with argv") {
197
197
const auto &cpp_widget = py_widget.cast <const Widget &>();
198
198
REQUIRE (cpp_widget.argv0 () == " a.out" );
199
199
}
200
+
201
+ {
202
+ PyConfig config;
203
+ PyConfig_InitPythonConfig (&config);
204
+
205
+ // Parse arguments the way python normally does, and strip the first argument (which is
206
+ // expected to be "python")
207
+ char *argv[] = {strdup (" python" ), strdup (" a.out" )};
208
+ py::scoped_interpreter argv_scope (&config, 2 , argv);
209
+ std::free (argv[0 ]);
210
+ std::free (argv[1 ]);
211
+ auto module = py::module::import (" test_interpreter" );
212
+ auto py_widget = module.attr (" DerivedWidget" )(" The question" );
213
+ const auto &cpp_widget = py_widget.cast <const Widget &>();
214
+ REQUIRE (cpp_widget.argv0 () == " a.out" );
215
+ }
200
216
py::initialize_interpreter ();
201
217
}
202
218
#endif
You can’t perform that action at this time.
0 commit comments