Commit 12700fda authored by mathieui's avatar mathieui

Merge branch 'tabs-slice' into 'master'

Allow Tabs object to be sliced

See merge request poezio/poezio!11
parents 2a755897 65649e91
......@@ -67,10 +67,10 @@ class Tabs:
def __iter__(self):
return iter(self._tabs)
def __getitem__(self, index: Union[int, str]):
if isinstance(index, int):
return self._tabs[index]
return self.by_name(index)
def __getitem__(self, index: Union[int, str, slice]):
if isinstance(index, str):
return self.by_name(index)
return self._tabs[index]
def first(self) -> tabs.Tab:
"""Return the Roster tab"""
......@@ -172,3 +172,14 @@ def test_set_current():
assert tabs.current_tab is dummy2
def test_slice():
tabs = Tabs(h)
dummy = DummyTab()
dummy2 = DummyTab()
dummy3 = DummyTab()
assert tabs[1:2][0] is dummy2
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment