Do not crash in tests if python is disabled in runtime
This commit is contained in:
parent
0fbc78d810
commit
37bc760cca
@ -8,6 +8,12 @@
|
||||
|
||||
#ifdef MOO_ENABLE_PYTHON
|
||||
|
||||
gboolean
|
||||
moo_python_enabled (void)
|
||||
{
|
||||
return Py_IsInitialized ();
|
||||
}
|
||||
|
||||
struct MooPythonState
|
||||
{
|
||||
PyObject *locals;
|
||||
@ -107,6 +113,8 @@ moo_python_state_new (gboolean default_init)
|
||||
{
|
||||
MooPythonState *state;
|
||||
|
||||
g_return_val_if_fail (moo_python_enabled (), NULL);
|
||||
|
||||
state = g_slice_new0 (MooPythonState);
|
||||
state->locals = create_script_dict ("__script__");
|
||||
|
||||
@ -248,4 +256,11 @@ medit_python_run_file (const char *filename,
|
||||
}
|
||||
|
||||
#else /* !MOO_ENABLE_PYTHON */
|
||||
|
||||
gboolean
|
||||
moo_python_enabled (void)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#endif /* !MOO_ENABLE_PYTHON */
|
||||
|
@ -41,9 +41,12 @@ add_test (MooTestSuite *suite, const char *name, const char *description, const
|
||||
void
|
||||
moo_test_python (void)
|
||||
{
|
||||
MooTestSuite *suite;
|
||||
if (moo_python_enabled ())
|
||||
{
|
||||
MooTestSuite *suite;
|
||||
|
||||
suite = moo_test_suite_new ("MooPython", "Python scripting tests", NULL, NULL, NULL);
|
||||
suite = moo_test_suite_new ("MooPython", "Python scripting tests", NULL, NULL, NULL);
|
||||
|
||||
add_test (suite, "moo", "test of moo module", "test-python/testmoo.py");
|
||||
add_test (suite, "moo", "test of moo module", "test-python/testmoo.py");
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user