blob: e3aabc8889f4a04cbc50451c1f8ccd9a74ec4ba0 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
  | 
#include "test.h"
#include <Python.h>
#include <library/cpp/testing/unittest/registar.h>
TTestPyInvoker::TTestPyInvoker() {}
const char* TTestPyInvoker::GetVersion() {
    Py_Initialize();
    auto* module = PyImport_ImportModule("sys");
    UNIT_ASSERT(module != nullptr);
    auto* versionObj = PyObject_GetAttrString(module, "version");
    if (versionObj == nullptr) {
        Py_DECREF(module);
        UNIT_ASSERT(versionObj != nullptr);
    }
    return Py_GetVersion();
}
  |