Skip to content

Commit e65d2e0

Browse files
authored
🔀 Merge pull request #6 from davep/test-check-time-travel-options
Test history's `can_go_forward` and `can_go_backward`
2 parents 65f7444 + 1f6c24e commit e65d2e0

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tests/unit/test_history.py

+14
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ def test_empty_history_has_no_length() -> None:
3131
assert len(History()) == 0
3232

3333

34+
##############################################################################
35+
def test_empty_history_has_nowhere_to_go() -> None:
36+
"""An empty history should not be able to move."""
37+
assert History().can_go_backward is False
38+
assert History().can_go_forward is False
39+
40+
3441
##############################################################################
3542
@mark.parametrize("initial", ([1], [1, 2], range(100)))
3643
def test_pre_populate_history_has_location(initial: Sequence[int]) -> None:
@@ -105,10 +112,13 @@ def test_backward() -> None:
105112
"""We should be able to move backward through history until we can't."""
106113
history = History[int]([1, 2, 3])
107114
assert history.current_location == 2
115+
assert history.can_go_backward is True
108116
assert history.backward() is True
109117
assert history.current_location == 1
118+
assert history.can_go_backward is True
110119
assert history.backward() is True
111120
assert history.current_location == 0
121+
assert history.can_go_backward is False
112122
assert history.backward() is False
113123
assert history.current_location == 0
114124

@@ -129,11 +139,15 @@ def test_forward() -> None:
129139
assert history.backward() is True
130140
assert history.backward() is True
131141
assert history.backward() is False
142+
assert history.can_go_backward is False
132143
assert history.current_location == 0
144+
assert history.can_go_forward is True
133145
assert history.forward() is True
134146
assert history.current_location == 1
147+
assert history.can_go_forward is True
135148
assert history.forward() is True
136149
assert history.current_location == 2
150+
assert history.can_go_forward is False
137151
assert history.forward() is False
138152
assert history.current_location == 2
139153

0 commit comments

Comments
 (0)