Skip to content

Commit 85349b7

Browse files
committed
tweak(fetch_objs): Raise ObjectDoesNotExist if object not found
1 parent a538072 commit 85349b7

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/libtmux/neo.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import typing as t
44

55
from libtmux import exc
6+
from libtmux._internal.query_list import ObjectDoesNotExist
67
from libtmux.common import tmux_cmd
78
from libtmux.formats import FORMAT_SEPARATOR
89

@@ -239,6 +240,12 @@ def fetch_obj(
239240
if _obj.get(obj_key) == obj_id:
240241
obj = _obj
241242

243+
if obj is None:
244+
raise ObjectDoesNotExist(
245+
f"Could not find {obj_key}={obj_id} for {list_cmd} "
246+
f'{list_extra_args if list_extra_args is not None else ""}'
247+
)
248+
242249
assert obj is not None
243250

244251
return obj

tests/test_window.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import pytest
88

99
from libtmux import exc
10+
from libtmux._internal.query_list import ObjectDoesNotExist
1011
from libtmux.common import has_gte_version, has_lt_version
1112
from libtmux.pane import Pane
1213
from libtmux.server import Server
@@ -205,7 +206,7 @@ def test_kill_window(session: Session) -> None:
205206
w.window_id
206207

207208
w.kill_window()
208-
with pytest.raises(AssertionError): # TODO: Replace this will an object not found
209+
with pytest.raises(ObjectDoesNotExist):
209210
w.refresh()
210211

211212

0 commit comments

Comments
 (0)