aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/python/ut/lib/test.cpp
blob: 824b7460e17e47d0c64c4708c88298e7035d5cff (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(); 
}