diff options
author | arcadia-devtools <arcadia-devtools@yandex-team.ru> | 2022-04-26 13:38:24 +0300 |
---|---|---|
committer | arcadia-devtools <arcadia-devtools@yandex-team.ru> | 2022-04-26 13:38:24 +0300 |
commit | d5542c891803641fb11f2edf0d71e6004a5e9c38 (patch) | |
tree | 592fd52d5412775f103fab3beb0083c08de7837f /library/cpp/testing/unittest/pytests | |
parent | e42e29335e2001970f95535e7557d5c27519f29f (diff) | |
download | ydb-d5542c891803641fb11f2edf0d71e6004a5e9c38.tar.gz |
intermediate changes
ref:ba3b994bce107b5d5ed74af8bebe6df02576505a
Diffstat (limited to 'library/cpp/testing/unittest/pytests')
-rw-r--r-- | library/cpp/testing/unittest/pytests/test_subject/tests.cpp | 34 | ||||
-rw-r--r-- | library/cpp/testing/unittest/pytests/test_tear_down.py | 17 |
2 files changed, 51 insertions, 0 deletions
diff --git a/library/cpp/testing/unittest/pytests/test_subject/tests.cpp b/library/cpp/testing/unittest/pytests/test_subject/tests.cpp new file mode 100644 index 00000000000..677e5130edd --- /dev/null +++ b/library/cpp/testing/unittest/pytests/test_subject/tests.cpp @@ -0,0 +1,34 @@ +#include <library/cpp/testing/unittest/registar.h> + +namespace NSubjectTests { + class TAlwaysTearDownFixture : public NUnitTest::TBaseFixture { + public: + void TearDown(NUnitTest::TTestContext&) override { + Cerr << Name_ << ": TearDown is ran" << Endl; + } + }; + + class TAlwaysTearDownSetUpThrowsFixture : public NUnitTest::TBaseFixture { + public: + void SetUp(NUnitTest::TTestContext&) override { + ythrow yexception() << "hope this won't skip teardown"; + } + + void TearDown(NUnitTest::TTestContext&) override { + Cerr << Name_ << ": TearDown is ran" << Endl; + } + }; + + Y_UNIT_TEST_SUITE(TestsAlwaysTearDown) { + Y_UNIT_TEST_F(TestFail, TAlwaysTearDownFixture) { + UNIT_ASSERT(false); + } + + Y_UNIT_TEST_F(TestThrow, TAlwaysTearDownFixture) { + ythrow yexception() << "hope this won't skip teardown"; + } + + Y_UNIT_TEST_F(TestSetUpThrows, TAlwaysTearDownSetUpThrowsFixture) { + } + } +} diff --git a/library/cpp/testing/unittest/pytests/test_tear_down.py b/library/cpp/testing/unittest/pytests/test_tear_down.py new file mode 100644 index 00000000000..5aec40198da --- /dev/null +++ b/library/cpp/testing/unittest/pytests/test_tear_down.py @@ -0,0 +1,17 @@ +import yatest.common as ya_common + + +def test_sanity(): + test_path = ya_common.binary_path("library/cpp/testing/unittest/pytests/test_subject/library-cpp-testing-unittest-pytests-test_subject") + + tests = ya_common.execute([test_path, '-A']).std_out \ + .decode().strip().split('\n') + + assert tests + + for test in tests: + name = test.split('::')[1] + res = ya_common.execute([test_path, test], check_exit_code=False) + assert res.exit_code != 0 + lines = res.std_err.decode().split('\n') + assert f"{name}: TearDown is ran" in lines |