mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Run black over recent immutable sequence view tests
Now that we're running black on tests...
This commit is contained in:
@@ -3,6 +3,7 @@ import pytest
|
|||||||
from typing import Sequence
|
from typing import Sequence
|
||||||
from textual._immutable_sequence_view import ImmutableSequenceView
|
from textual._immutable_sequence_view import ImmutableSequenceView
|
||||||
|
|
||||||
|
|
||||||
def wrap(source: Sequence[int]) -> ImmutableSequenceView[int]:
|
def wrap(source: Sequence[int]) -> ImmutableSequenceView[int]:
|
||||||
"""Wrap a sequence of integers inside an immutable sequence view."""
|
"""Wrap a sequence of integers inside an immutable sequence view."""
|
||||||
return ImmutableSequenceView[int](source)
|
return ImmutableSequenceView[int](source)
|
||||||
@@ -24,7 +25,7 @@ def test_non_empty_immutable_sequence() -> None:
|
|||||||
|
|
||||||
def test_no_assign_to_immutable_sequence() -> None:
|
def test_no_assign_to_immutable_sequence() -> None:
|
||||||
"""It should not be possible to assign into an immutable sequence."""
|
"""It should not be possible to assign into an immutable sequence."""
|
||||||
tester = wrap([1,2,3,4,5])
|
tester = wrap([1, 2, 3, 4, 5])
|
||||||
with pytest.raises(TypeError):
|
with pytest.raises(TypeError):
|
||||||
tester[0] = 23
|
tester[0] = 23
|
||||||
with pytest.raises(TypeError):
|
with pytest.raises(TypeError):
|
||||||
@@ -33,7 +34,7 @@ def test_no_assign_to_immutable_sequence() -> None:
|
|||||||
|
|
||||||
def test_no_del_from_iummutable_sequence() -> None:
|
def test_no_del_from_iummutable_sequence() -> None:
|
||||||
"""It should not be possible delete an item from an immutable sequence."""
|
"""It should not be possible delete an item from an immutable sequence."""
|
||||||
tester = wrap([1,2,3,4,5])
|
tester = wrap([1, 2, 3, 4, 5])
|
||||||
with pytest.raises(TypeError):
|
with pytest.raises(TypeError):
|
||||||
del tester[0]
|
del tester[0]
|
||||||
|
|
||||||
@@ -46,23 +47,23 @@ def test_get_item_from_immutable_sequence() -> None:
|
|||||||
|
|
||||||
def test_get_slice_from_immutable_sequence() -> None:
|
def test_get_slice_from_immutable_sequence() -> None:
|
||||||
"""It should be possible to get a slice from an immutable sequence."""
|
"""It should be possible to get a slice from an immutable sequence."""
|
||||||
assert list(wrap(range(10))[0:2]) == [0,1]
|
assert list(wrap(range(10))[0:2]) == [0, 1]
|
||||||
assert list(wrap(range(10))[0:-1]) == [0,1,2,3,4,5,6,7,8]
|
assert list(wrap(range(10))[0:-1]) == [0, 1, 2, 3, 4, 5, 6, 7, 8]
|
||||||
|
|
||||||
|
|
||||||
def test_immutable_sequence_contains() -> None:
|
def test_immutable_sequence_contains() -> None:
|
||||||
"""It should be possible to see if an immutable sequence contains a value."""
|
"""It should be possible to see if an immutable sequence contains a value."""
|
||||||
tester = wrap([1,2,3,4,5])
|
tester = wrap([1, 2, 3, 4, 5])
|
||||||
assert 1 in tester
|
assert 1 in tester
|
||||||
assert 11 not in tester
|
assert 11 not in tester
|
||||||
|
|
||||||
|
|
||||||
def test_immutable_sequence_index() -> None:
|
def test_immutable_sequence_index() -> None:
|
||||||
tester = wrap([1,2,3,4,5])
|
tester = wrap([1, 2, 3, 4, 5])
|
||||||
assert tester.index(1) == 0
|
assert tester.index(1) == 0
|
||||||
with pytest.raises(ValueError):
|
with pytest.raises(ValueError):
|
||||||
_ = tester.index(11)
|
_ = tester.index(11)
|
||||||
|
|
||||||
|
|
||||||
def test_reverse_immutable_sequence() -> None:
|
def test_reverse_immutable_sequence() -> None:
|
||||||
assert list(reversed(wrap([1,2]))) == [2,1]
|
assert list(reversed(wrap([1, 2]))) == [2, 1]
|
||||||
|
|||||||
Reference in New Issue
Block a user