aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/python/ut
diff options
context:
space:
mode:
authorDevtools Arcadia <arcadia-devtools@yandex-team.ru>2022-02-07 18:08:42 +0300
committerDevtools Arcadia <arcadia-devtools@mous.vla.yp-c.yandex.net>2022-02-07 18:08:42 +0300
commit1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch)
treee26c9fed0de5d9873cce7e00bc214573dc2195b7 /contrib/libs/python/ut
downloadydb-1110808a9d39d4b808aef724c861a2e1a38d2a69.tar.gz
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'contrib/libs/python/ut')
-rw-r--r--contrib/libs/python/ut/lib/test.cpp21
-rw-r--r--contrib/libs/python/ut/lib/test.h7
-rw-r--r--contrib/libs/python/ut/lib/ya.make17
-rw-r--r--contrib/libs/python/ut/py2/use.cpp10
-rw-r--r--contrib/libs/python/ut/py2/ya.make9
-rw-r--r--contrib/libs/python/ut/py3/use.cpp10
-rw-r--r--contrib/libs/python/ut/py3/ya.make10
-rw-r--r--contrib/libs/python/ut/ya.make7
8 files changed, 91 insertions, 0 deletions
diff --git a/contrib/libs/python/ut/lib/test.cpp b/contrib/libs/python/ut/lib/test.cpp
new file mode 100644
index 0000000000..e3aabc8889
--- /dev/null
+++ b/contrib/libs/python/ut/lib/test.cpp
@@ -0,0 +1,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();
+}
diff --git a/contrib/libs/python/ut/lib/test.h b/contrib/libs/python/ut/lib/test.h
new file mode 100644
index 0000000000..1bf824ebea
--- /dev/null
+++ b/contrib/libs/python/ut/lib/test.h
@@ -0,0 +1,7 @@
+#pragma once
+
+class TTestPyInvoker {
+public:
+ TTestPyInvoker();
+ const char* GetVersion();
+};
diff --git a/contrib/libs/python/ut/lib/ya.make b/contrib/libs/python/ut/lib/ya.make
new file mode 100644
index 0000000000..cfa0aaa612
--- /dev/null
+++ b/contrib/libs/python/ut/lib/ya.make
@@ -0,0 +1,17 @@
+OWNER(spreis)
+
+PY23_LIBRARY()
+
+WITHOUT_LICENSE_TEXTS()
+
+LICENSE(YandexOpen)
+
+PEERDIR(
+ library/cpp/testing/unittest
+)
+
+SRCS(
+ test.cpp
+)
+
+END()
diff --git a/contrib/libs/python/ut/py2/use.cpp b/contrib/libs/python/ut/py2/use.cpp
new file mode 100644
index 0000000000..a4a2c8d9bb
--- /dev/null
+++ b/contrib/libs/python/ut/py2/use.cpp
@@ -0,0 +1,10 @@
+#include <contrib/libs/python/ut/lib/test.h>
+#include <library/cpp/testing/unittest/registar.h>
+
+Y_UNIT_TEST_SUITE(TestPy3Binding) {
+ Y_UNIT_TEST(version) {
+ TTestPyInvoker invoker;
+ UNIT_ASSERT_EQUAL(invoker.GetVersion()[0], '2');
+ }
+}
+
diff --git a/contrib/libs/python/ut/py2/ya.make b/contrib/libs/python/ut/py2/ya.make
new file mode 100644
index 0000000000..9c5c824761
--- /dev/null
+++ b/contrib/libs/python/ut/py2/ya.make
@@ -0,0 +1,9 @@
+OWNER(spreis)
+
+UNITTEST()
+SRCS(use.cpp)
+
+PEERDIR(
+ contrib/libs/python/ut/lib
+)
+END()
diff --git a/contrib/libs/python/ut/py3/use.cpp b/contrib/libs/python/ut/py3/use.cpp
new file mode 100644
index 0000000000..8a2531bcc1
--- /dev/null
+++ b/contrib/libs/python/ut/py3/use.cpp
@@ -0,0 +1,10 @@
+#include <contrib/libs/python/ut/lib/test.h>
+#include <library/cpp/testing/unittest/registar.h>
+
+Y_UNIT_TEST_SUITE(TestPy3Binding) {
+ Y_UNIT_TEST(version) {
+ TTestPyInvoker invoker;
+ UNIT_ASSERT_EQUAL(invoker.GetVersion()[0], '3');
+ }
+}
+
diff --git a/contrib/libs/python/ut/py3/ya.make b/contrib/libs/python/ut/py3/ya.make
new file mode 100644
index 0000000000..df6d4fe767
--- /dev/null
+++ b/contrib/libs/python/ut/py3/ya.make
@@ -0,0 +1,10 @@
+OWNER(spreis)
+
+UNITTEST()
+USE_PYTHON3()
+SRCS(use.cpp)
+
+PEERDIR(
+ contrib/libs/python/ut/lib
+)
+END()
diff --git a/contrib/libs/python/ut/ya.make b/contrib/libs/python/ut/ya.make
new file mode 100644
index 0000000000..4fea35153a
--- /dev/null
+++ b/contrib/libs/python/ut/ya.make
@@ -0,0 +1,7 @@
+OWNER(spreis)
+
+RECURSE(
+ lib
+ py2
+ py3
+) \ No newline at end of file