From 4746be4e7d8a883476160a3756105393f9d5b4f6 Mon Sep 17 00:00:00 2001 From: robot-piglet Date: Wed, 11 Dec 2024 09:19:45 +0300 Subject: Intermediate changes commit_hash:a633306b66f89adbf188bf9c6d521bdf7b01f82f --- library/python/pytest/plugins/collection.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'library/python') diff --git a/library/python/pytest/plugins/collection.py b/library/python/pytest/plugins/collection.py index aa3f51cfef0..7ca8efc47e9 100644 --- a/library/python/pytest/plugins/collection.py +++ b/library/python/pytest/plugins/collection.py @@ -85,20 +85,32 @@ class DoctestModule(LoadedModule): reraise(etype, type(exc)('{}\n{}'.format(exc, msg)), tb) +def _is_skipped_module_level(module): + # since we import module by ourselves when CONFTEST_LOAD_POLICY is set to LOCAL we have to handle + # pytest.skip.Exception https://docs.pytest.org/en/stable/reference/reference.html#pytest-skip + try: + module.obj + except pytest.skip.Exception: + return True + except Exception: + # letting other exceptions such as ImportError slip through + pass + return False + + # NOTE: Since we are overriding collect method of pytest session, pytest hooks are not invoked during collection. def pytest_ignore_collect(module, session, filenames_from_full_filters, accept_filename_predicate): if session.config.option.mode == 'list': - return not accept_filename_predicate(module.name) + return not accept_filename_predicate(module.name) or _is_skipped_module_level(module) if filenames_from_full_filters is not None and module.name not in filenames_from_full_filters: return True test_file_filter = getattr(session.config.option, 'test_file_filter', None) - if test_file_filter is None: - return False - if module.name != test_file_filter.replace('/', '.'): + if test_file_filter and module.name != test_file_filter.replace('/', '.'): return True - return False + + return _is_skipped_module_level(module) class CollectionPlugin(object): -- cgit v1.3 From 2fa0ef191a3e4958ba689ecdc0aabc756385ca13 Mon Sep 17 00:00:00 2001 From: thegeorg Date: Thu, 12 Dec 2024 13:15:03 +0300 Subject: Switch all tests to atd from snapshot commit_hash:a9a7c2df09742a540851227c4fcb7d925edd9793 --- library/cpp/testing/common/env.cpp | 26 +--------------------- library/cpp/testing/common/ut/env_ut.cpp | 18 --------------- .../testing/yatest_common/yatest/common/runtime.py | 6 ++--- 3 files changed, 4 insertions(+), 46 deletions(-) (limited to 'library/python') diff --git a/library/cpp/testing/common/env.cpp b/library/cpp/testing/common/env.cpp index 67e081c371c..1440186d789 100644 --- a/library/cpp/testing/common/env.cpp +++ b/library/cpp/testing/common/env.cpp @@ -41,31 +41,7 @@ TString BinaryPath(TStringBuf path) { } TString GetArcadiaTestsData() { - if (GetEnv("USE_ATD_FROM_SNAPSHOT")) { - return ArcadiaSourceRoot() + "/atd_ro_snapshot"; - } - - TString atdRoot = NPrivate::GetTestEnv().ArcadiaTestsDataDir; - if (atdRoot) { - return atdRoot; - } - - TString path = NPrivate::GetCwd(); - const char pathsep = GetDirectorySeparator(); - while (!path.empty()) { - TString dataDir = path + "/arcadia_tests_data"; - if (IsDir(dataDir)) { - return dataDir; - } - - size_t pos = path.find_last_of(pathsep); - if (pos == TString::npos) { - pos = 0; - } - path.erase(pos); - } - - return {}; + return ArcadiaSourceRoot() + "/atd_ro_snapshot"; } TString GetWorkPath() { diff --git a/library/cpp/testing/common/ut/env_ut.cpp b/library/cpp/testing/common/ut/env_ut.cpp index fe4946a65f3..4b67d05efb4 100644 --- a/library/cpp/testing/common/ut/env_ut.cpp +++ b/library/cpp/testing/common/ut/env_ut.cpp @@ -45,24 +45,6 @@ TEST(Runtime, BinaryPath) { EXPECT_TRUE(TFsPath(BinaryPath("library/cpp/testing/common/ut")).Exists()); } -TEST(Runtime, GetArcadiaTestsData) { - NTesting::TScopedEnvironment contextGuard("YA_TEST_CONTEXT_FILE", ""); // remove context filename - { - auto tmpDir = ::GetSystemTempDir(); - NTesting::TScopedEnvironment guard("ARCADIA_TESTS_DATA_DIR", tmpDir); - Singleton()->ReInitialize(); - EXPECT_EQ(tmpDir, GetArcadiaTestsData()); - } - { - NTesting::TScopedEnvironment guard("ARCADIA_TESTS_DATA_DIR", ""); - Singleton()->ReInitialize(); - auto path = GetArcadiaTestsData(); - // it is not error if path is empty - const bool ok = (path.empty() || GetBaseName(path) == "arcadia_tests_data"); - EXPECT_TRUE(ok); - } -} - TEST(Runtime, GetWorkPath) { NTesting::TScopedEnvironment contextGuard("YA_TEST_CONTEXT_FILE", ""); // remove context filename { diff --git a/library/python/testing/yatest_common/yatest/common/runtime.py b/library/python/testing/yatest_common/yatest/common/runtime.py index e4f246d5c83..99a6799109b 100644 --- a/library/python/testing/yatest_common/yatest/common/runtime.py +++ b/library/python/testing/yatest_common/yatest/common/runtime.py @@ -190,9 +190,9 @@ def data_path(path=None): :param path: path relative to the arcadia_tests_data directory, e.g. yatest.common.data_path("pers/rerank_service") :return: absolute path inside arcadia_tests_data """ - if "USE_ATD_FROM_SNAPSHOT" in os.environ: - return os.path.join(source_path(), "atd_ro_snapshot", path) - return _join_path(_get_ya_plugin_instance().data_root, path) + if "USE_ATD_FROM_ATD" in os.environ: + return _join_path(_get_ya_plugin_instance().data_root, path) + return _join_path(source_path("atd_ro_snapshot"), path) @default_arg0 -- cgit v1.3