|
9 | 9 | #include "gtest/gtest.h"
|
10 | 10 |
|
11 | 11 | #include "Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h"
|
12 |
| -#include "Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h" |
13 |
| -#include "Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h" |
14 | 12 | #include "Plugins/ScriptInterpreter/Python/lldb-python.h"
|
15 | 13 |
|
16 |
| -#include "lldb/Host/FileSystem.h" |
17 |
| -#include "lldb/Host/HostInfo.h" |
18 |
| - |
19 | 14 | #include "PythonTestSuite.h"
|
20 | 15 |
|
21 |
| -using namespace lldb_private; |
22 |
| -class TestScriptInterpreterPython : public ScriptInterpreterPythonImpl { |
23 |
| -public: |
24 |
| - using ScriptInterpreterPythonImpl::Initialize; |
25 |
| -}; |
26 |
| - |
27 | 16 | void PythonTestSuite::SetUp() {
|
28 |
| - FileSystem::Initialize(); |
29 |
| - HostInfoBase::Initialize(); |
30 |
| - // ScriptInterpreterPython::Initialize() depends on HostInfo being |
31 |
| - // initializedso it can compute the python directory etc. |
32 |
| - TestScriptInterpreterPython::Initialize(); |
33 |
| - |
34 | 17 | // Although we don't care about concurrency for the purposes of running
|
35 | 18 | // this test suite, Python requires the GIL to be locked even for
|
36 | 19 | // deallocating memory, which can happen when you call Py_DECREF or
|
37 | 20 | // Py_INCREF. So acquire the GIL for the entire duration of this
|
38 | 21 | // test suite.
|
| 22 | + Py_InitializeEx(0); |
39 | 23 | m_gil_state = PyGILState_Ensure();
|
| 24 | + PyRun_SimpleString("import sys"); |
40 | 25 | }
|
41 | 26 |
|
42 | 27 | void PythonTestSuite::TearDown() {
|
43 | 28 | PyGILState_Release(m_gil_state);
|
44 | 29 |
|
45 |
| - TestScriptInterpreterPython::Terminate(); |
46 |
| - HostInfoBase::Terminate(); |
47 |
| - FileSystem::Terminate(); |
| 30 | + // We could call Py_FinalizeEx here, but initializing and finalizing Python is |
| 31 | + // pretty slow, so just keep Python initialized across tests. |
48 | 32 | }
|
49 | 33 |
|
50 | 34 | // The following functions are the Pythonic implementations of the required
|
|
0 commit comments