diff options
| author | robot-piglet <[email protected]> | 2026-03-03 12:27:28 +0300 |
|---|---|---|
| committer | robot-piglet <[email protected]> | 2026-03-03 14:10:14 +0300 |
| commit | 200fe48de75f260e5782b72768630c45b073c5bb (patch) | |
| tree | a823ce3c1d488c7b4ce4093eb78993f124ecd41c /library/python/pytest | |
| parent | d29e1eafd7359dc59db71f0773cf51c7e7d43a66 (diff) | |
Intermediate changes
commit_hash:85afa7bf1a79b5728ecd004afa11afa9a603f9ea
Diffstat (limited to 'library/python/pytest')
| -rw-r--r-- | library/python/pytest/module_utils.py | 2 | ||||
| -rw-r--r-- | library/python/pytest/plugins/conftests.py | 3 | ||||
| -rw-r--r-- | library/python/pytest/rewrite.py | 9 |
3 files changed, 10 insertions, 4 deletions
diff --git a/library/python/pytest/module_utils.py b/library/python/pytest/module_utils.py index a26deccfecb..4775ba37448 100644 --- a/library/python/pytest/module_utils.py +++ b/library/python/pytest/module_utils.py @@ -56,7 +56,7 @@ _BASE_PATHS = None def get_proper_module_path(module_name): """ Get the file path for a test module relative to the repository root. - For synthesized empty __init__.py modules, returns module_name as a fake file path. + For synthesized empty __init__.py modules, returns None. """ global _BASE_PATHS if _BASE_PATHS is None: diff --git a/library/python/pytest/plugins/conftests.py b/library/python/pytest/plugins/conftests.py index d5c0a4f1947..33701fd7452 100644 --- a/library/python/pytest/plugins/conftests.py +++ b/library/python/pytest/plugins/conftests.py @@ -80,7 +80,8 @@ _conftest_modules = [] def pytest_load_initial_conftests(early_config): pluginmanager = early_config.pluginmanager - conftests = filter(lambda name: name.endswith('.conftest'), getattr(sys, 'extra_modules', [])) + extra_modules = getattr(sys, 'extra_modules', []) + conftests = filter(lambda name: name == 'conftest' or name.endswith('.conftest'), extra_modules) if os.getenv('CONFTEST_LOAD_POLICY') == 'LOCAL': test_dir = str(yatest.common.context.project_path) diff --git a/library/python/pytest/rewrite.py b/library/python/pytest/rewrite.py index 4ca44e1fb35..df3c1cca29b 100644 --- a/library/python/pytest/rewrite.py +++ b/library/python/pytest/rewrite.py @@ -21,6 +21,8 @@ from __res import importer import sys import six +import library.python.pytest.module_utils as module_utils + def _get_state(config): if hasattr(config, '_assertstate'): @@ -53,7 +55,10 @@ class AssertionRewritingHook(rewrite.AssertionRewritingHook): if hasattr(self._rewritten_names, 'add'): self._rewritten_names.add(name) else: - self._rewritten_names[name] = Path(path[0]) + if path: + self._rewritten_names[name] = Path(path[0]) + else: + self._rewritten_names[name] = Path(module_utils.get_proper_module_path(name)) state.trace("rewriting %s" % name) co = _rewrite_test(self.config, name) @@ -73,7 +78,7 @@ class AssertionRewritingHook(rewrite.AssertionRewritingHook): ) def _should_rewrite(self, name, fn, state): - if name.startswith("__tests__.") or name.endswith(".conftest"): + if name.startswith("__tests__.") or name == "conftest" or name.endswith(".conftest"): return True return self._is_marked_for_rewrite(name, state) |
