`retry_until()`: Improve pytest error message via rewriting
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 42/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- python
- 領域
- testing-qa
調査の方向性
Start with the retry_until() entry point shown in the traceback and run tests/test_workspacebuilder.py::test_automatic_rename_option to reproduce the current failure. Investigate pytest assertion rewriting and make the timeout failure retain the higher-level assertion context, ending with the reported WaitTimeout in check_window_name_match() wording.
索引モデルが issue の本文から書いたものです。
説明
#372 added retry_until()
pytest assertion rewriting provides pytest_assertrepr_compare().
Now
________________________________________________ test_automatic_rename_option ________________________________________________
session = Session($1 libtmux_yn08bma4)
def test_automatic_rename_option(session):
"""With option automatic-rename: on."""
yaml_config = test_utils.read_config_file(
"workspacebuilder/window_automatic_rename.yaml"
)
s = session
sconfig = kaptan.Kaptan(handler="yaml") [56/238] sconfig = sconfig.import_config(yaml_config).get()
# This should be a command guaranteed to be terminal name across systems
portable_command = sconfig["windows"][0]["panes"][0]["shell_command"][0]["cmd"]
# If a command is like "man ls", get the command base name, "ls"
if " " in portable_command:
portable_command = portable_command.split(" ")[0]
builder = WorkspaceBuilder(sconf=sconfig)
window_count = len(session._windows) # current window count
assert len(s._windows) == window_count
for w, wconf in builder.iter_create_windows(s):
for p in builder.iter_create_panes(w, wconf):
w.select_layout("tiled") # fix glitch with pane size
p = p
assert len(s._windows), window_count
assert isinstance(w, Window)
assert w.show_window_option("automatic-rename") == "on"
assert len(s._windows) == window_count
window_count += 1
w.select_layout(wconf["layout"])
assert s.name != "tmuxp"
w = s.windows[0]
def check_window_name_mismatch() -> bool:
session.server._update_windows()
return w.name != portable_command
assert retry_until(check_window_name_mismatch, 2, interval=0.25)
pane_base_index = w.show_window_option("pane-base-index", g=True)
w.select_pane(pane_base_index)
def check_window_name_match() -> bool:
session.server._update_windows()
return w.name == portable_command
> assert retry_until(check_window_name_match, 2, interval=0.25)
tests/test_workspacebuilder.py:402:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
fun = <function test_automatic_rename_option.<locals>.check_window_name_match at 0x7f484aee43a0>, seconds = 2
def retry_until(
fun: Callable,
seconds: float = RETRY_TIMEOUT_SECONDS,
*,
interval: Optional[float] = RETRY_INTERVAL_SECONDS,
raises: Optional[bool] = True,
) -> bool: [0/238] """
Retry a function until a condition meets or the specified time passes.
Parameters
----------
fun : callable
A function that will be called repeatedly until it returns ``True`` or
the specified time passes.
seconds : float
Seconds to retry. Defaults to ``8``, which is configurable via
``RETRY_TIMEOUT_SECONDS`` environment variables.
interval : float
Time in seconds to wait between calls. Defaults to ``0.05`` and is
configurable via ``RETRY_INTERVAL_SECONDS`` environment variable.
raises : bool
Wether or not to raise an exception on timeout. Defaults to ``True``.
Examples
--------
>>> def f():
... p = w.attached_pane
... p.server._update_panes()
... return p.current_path == pane_path
...
... retry(f)
In pytest:
>>> assert retry(f, raises=False)
"""
ini = time.time()
while not fun():
end = time.time()
if end - ini >= seconds:
if raises:
> raise WaitTimeout()
E libtmux.exc.WaitTimeout
.venv/lib/python3.10/site-packages/libtmux/test.py:103: WaitTimeout
FAILED tests/test_workspacebuilder.py::test_automatic_rename_option - libtmux.exc.WaitTimeout
What we want
We want the higher level frame in the stack:
def check_window_name_match() -> bool:
session.server._update_windows()
return w.name == portable_command
> assert retry_until(check_window_name_match, 2, interval=0.25)
.venv/lib/python3.10/site-packages/libtmux/test.py:103: WaitTimeout
FAILED tests/test_workspacebuilder.py::test_automatic_rename_option - libtmux.exc.WaitTimeout in check_window_name_match()
- 主要言語
- Python
- スター
- 1.2k
- フォーク
- 127
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
tmux-python/libtmux のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
tmux-python/libtmux#759 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
tmux-python/libtmux#745 · コメント 2 件 ·
-
Documentation: how to use internal libtmux logging対応中かも @tony が 47 日前に担当しました。 オープンenhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
tmux-python/libtmux#744 ·
-
`test_control_mode_stdout_preserves_non_ascii_output` polls `select` on a buffered stream対応中かも @tony が 69 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
tmux-python/libtmux#731 ·
-
Flaky test: test_capture_pane_flags[join_wrapped_numbers] matches marker in command echo対応中かも @tony が 189 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
tmux-python/libtmux#654 ·
tmux-python/libtmux の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
UKGovernmentBEIS/inspect_ai#5781 ·
メンテナーはふだん 2 日以内に返信
-
Bump .cicd to wamp-cicd 4c2f9ac: `just land` refuses open A18 decisions, `just where` lists themオープン
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
crossbario/cfxdb#139 ·
-
Bump .cicd to wamp-cicd 4c2f9ac: `just land` refuses open A18 decisions, `just where` lists themオープン
難易度 1/5 1時間未満 初心者へのやさしさ 84/100
crossbario/txaio#241 ·
-
UX
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
mediajunkie/piper-morgan-product#1963 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100