()
| 12 | |
| 13 | |
| 14 | def main(): |
| 15 | import library.python.pytest.context as context |
| 16 | |
| 17 | context.Ctx["YA_PYTEST_START_TIMESTAMP"] = time.time() |
| 18 | |
| 19 | profile = None |
| 20 | if '--profile-pytest' in sys.argv: |
| 21 | sys.argv.remove('--profile-pytest') |
| 22 | |
| 23 | import pstats |
| 24 | import cProfile |
| 25 | |
| 26 | profile = cProfile.Profile() |
| 27 | profile.enable() |
| 28 | |
| 29 | # Reset influencing env. vars |
| 30 | # For more info see library/python/testing/yatest_common/yatest/common/errors.py |
| 31 | if FORCE_EXIT_TESTSFAILED_ENV in os.environ: |
| 32 | del os.environ[FORCE_EXIT_TESTSFAILED_ENV] |
| 33 | |
| 34 | if "Y_PYTHON_CLEAR_ENTRY_POINT" in os.environ: |
| 35 | if "Y_PYTHON_ENTRY_POINT" in os.environ: |
| 36 | del os.environ["Y_PYTHON_ENTRY_POINT"] |
| 37 | del os.environ["Y_PYTHON_CLEAR_ENTRY_POINT"] |
| 38 | |
| 39 | listing_mode = '--collect-only' in sys.argv |
| 40 | yatest_runner = os.environ.get('YA_TEST_RUNNER') == '1' |
| 41 | |
| 42 | import pytest |
| 43 | |
| 44 | import library.python.pytest.plugins.collection as collection |
| 45 | import library.python.pytest.plugins.ya as ya |
| 46 | import library.python.pytest.plugins.conftests as conftests |
| 47 | |
| 48 | import _pytest.assertion |
| 49 | from _pytest.monkeypatch import MonkeyPatch |
| 50 | from . import rewrite |
| 51 | |
| 52 | m = MonkeyPatch() |
| 53 | m.setattr(_pytest.assertion.rewrite, "AssertionRewritingHook", rewrite.AssertionRewritingHook) |
| 54 | |
| 55 | # see https://st.yandex-team.ru/DEVTOOLSSUPPORT-50337 |
| 56 | m.setattr(_pytest.assertion.truncate, "DEFAULT_MAX_LINES", 16) |
| 57 | m.setattr(_pytest.assertion.truncate, "DEFAULT_MAX_CHARS", 32 * 80) |
| 58 | |
| 59 | yatest.common.runtime._set_ya_config(ya=yatest_lib.ya.Ya()) |
| 60 | |
| 61 | prefix = '__tests__.' |
| 62 | |
| 63 | test_modules = [ |
| 64 | # fmt: off |
| 65 | name |
| 66 | for name in sys.extra_modules |
| 67 | if name.startswith(prefix) and not name.endswith('.conftest') |
| 68 | # fmt: on |
| 69 | ] |
| 70 | |
| 71 | doctest_packages = __res.find("PY_DOCTEST_PACKAGES") or "" |
no test coverage detected