File tree 1 file changed +21
-1
lines changed
1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -184,7 +184,7 @@ TEST_CASE("Custom PyConfig") {
184
184
py::initialize_interpreter ();
185
185
}
186
186
187
- TEST_CASE (" Custom PyConfig with argv" ) {
187
+ TEST_CASE (" scoped_interpreter with PyConfig_InitIsolatedConfig and argv" ) {
188
188
py::finalize_interpreter ();
189
189
{
190
190
PyConfig config;
@@ -199,6 +199,26 @@ TEST_CASE("Custom PyConfig with argv") {
199
199
}
200
200
py::initialize_interpreter ();
201
201
}
202
+
203
+ TEST_CASE (" scoped_interpreter with PyConfig_InitPythonConfig and argv" ) {
204
+ py::finalize_interpreter ();
205
+ {
206
+ PyConfig config;
207
+ PyConfig_InitPythonConfig (&config);
208
+
209
+ // `initialize_interpreter() overrides the default value for config.parse_argv (`1`) by
210
+ // changing it to `0`. This test exercises `scoped_interpreter` with the default config.
211
+ char *argv[] = {strdup (" a.out" ), strdup (" arg1" )};
212
+ py::scoped_interpreter argv_scope (&config, 2 , argv);
213
+ std::free (argv[0 ]);
214
+ std::free (argv[1 ]);
215
+ auto module = py::module::import (" test_interpreter" );
216
+ auto py_widget = module.attr (" DerivedWidget" )(" The question" );
217
+ const auto &cpp_widget = py_widget.cast <const Widget &>();
218
+ REQUIRE (cpp_widget.argv0 () == " arg1" );
219
+ }
220
+ py::initialize_interpreter ();
221
+ }
202
222
#endif
203
223
204
224
TEST_CASE (" Add program dir to path pre-PyConfig" ) {
You can’t perform that action at this time.
0 commit comments