()
| 261 | |
| 262 | @pytest.mark.asyncio |
| 263 | async def test_navigable_provider(): |
| 264 | provider = NavigableAutoSuggestFromHistory() |
| 265 | history = InMemoryHistory(history_strings=["very_a", "very", "very_b", "very_c"]) |
| 266 | buffer = Buffer(history=history) |
| 267 | ip = get_ipython() |
| 268 | ip.auto_suggest = provider |
| 269 | |
| 270 | async for _ in history.load(): |
| 271 | pass |
| 272 | |
| 273 | buffer.cursor_position = 5 |
| 274 | buffer.text = "very" |
| 275 | |
| 276 | up = swap_autosuggestion_up |
| 277 | down = swap_autosuggestion_down |
| 278 | |
| 279 | event = Mock() |
| 280 | event.current_buffer = buffer |
| 281 | |
| 282 | def get_suggestion(): |
| 283 | suggestion = provider.get_suggestion(buffer, buffer.document) |
| 284 | buffer.suggestion = suggestion |
| 285 | return suggestion |
| 286 | |
| 287 | assert get_suggestion().text == "_c" |
| 288 | |
| 289 | # should go up |
| 290 | up(event) |
| 291 | assert get_suggestion().text == "_b" |
| 292 | |
| 293 | # should skip over 'very' which is identical to buffer content |
| 294 | up(event) |
| 295 | assert get_suggestion().text == "_a" |
| 296 | |
| 297 | # should cycle back to beginning |
| 298 | up(event) |
| 299 | assert get_suggestion().text == "_c" |
| 300 | |
| 301 | # should cycle back through end boundary |
| 302 | down(event) |
| 303 | assert get_suggestion().text == "_a" |
| 304 | |
| 305 | down(event) |
| 306 | assert get_suggestion().text == "_b" |
| 307 | |
| 308 | down(event) |
| 309 | assert get_suggestion().text == "_c" |
| 310 | |
| 311 | down(event) |
| 312 | assert get_suggestion().text == "_a" |
| 313 | |
| 314 | |
| 315 | @pytest.mark.asyncio |
nothing calls this directly
no test coverage detected
searching dependent graphs…