Andrey Epifancev 6fb42be8ff synthgen: ОСВ в оформлении 1С (#38)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-13 00:20:44 +04:00

46 lines
2.0 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""Общие настройки pytest для synthgen.
Маркеры:
- `parser` — приёмка парсером tabular-parser из зеркального worktree (переменная `TP_WT`);
без окружения такие тесты пропускаются.
- `slow` — долгие прогоны; по умолчанию пропускаются, запуск: `-m slow`.
"""
import os
from pathlib import Path
import pytest
def pytest_configure(config):
config.addinivalue_line("markers", "parser: приёмка парсером из зеркального worktree (TP_WT), без окружения — skip")
config.addinivalue_line("markers", "slow: долгий прогон, по умолчанию пропускается, запуск -m slow")
def pytest_collection_modifyitems(config, items):
markexpr = config.getoption("-m") or ""
tp_wt = os.environ.get("TP_WT")
parser_ready = bool(tp_wt) and Path(tp_wt).is_dir()
for item in items:
if "slow" in item.keywords and "slow" not in markexpr:
item.add_marker(pytest.mark.skip(reason="долгий прогон: запуск с -m slow"))
if "parser" in item.keywords and not parser_ready:
item.add_marker(pytest.mark.skip(reason="нужен TP_WT (зеркало tabular-parser)"))
@pytest.fixture(scope="session")
def osv_world():
"""Небольшая группа с книгами за 3 периода (для тестов ОСВ): (cfg, group, periods, books)."""
from synthgen import dictionary
from synthgen.config import Config
from synthgen.counterparties import plan as make_plan
from synthgen.group import build_group
from synthgen.intragroup import build
from synthgen.periods import build_periods
cfg = Config(group_size=4, periods=3, osv_counterparties_mean=8, no_inn_companies=1)
group = build_group(cfg, dictionary.load())
periods = build_periods(cfg.start, cfg.periods)
books, _ = build(cfg, group, periods, make_plan(cfg, group))
return cfg, group, periods, books