Tests that solving a model displays solver progress when the ``display`` argument is ``True``.
(ok_small, caplog)
| 375 | |
| 376 | |
| 377 | def test_model_solve_display_argument(ok_small, caplog): |
| 378 | """ |
| 379 | Tests that solving a model displays solver progress when the ``display`` |
| 380 | argument is ``True``. |
| 381 | """ |
| 382 | model = Model.from_data(ok_small) |
| 383 | |
| 384 | # First solve with display turned off. We should not see any output in this |
| 385 | # case. |
| 386 | model.solve(stop=MaxIterations(10), seed=0, display=False) |
| 387 | printed = caplog.text |
| 388 | assert_equal(printed, "") |
| 389 | |
| 390 | # Now solve with display turned on. We should see output now. |
| 391 | res = model.solve(stop=MaxIterations(10), seed=0, display=True) |
| 392 | printed = caplog.text |
| 393 | |
| 394 | # Check that some of the header data is in the output. |
| 395 | assert_("PyVRP" in printed) |
| 396 | assert_("Time" in printed) |
| 397 | assert_("Iters" in printed) |
| 398 | assert_("Current" in printed) |
| 399 | assert_("Candidate" in printed) |
| 400 | assert_("Best" in printed) |
| 401 | |
| 402 | # Check that we include the cost and total runtime in the output somewhere. |
| 403 | assert_(str(round(res.cost())) in printed) |
| 404 | assert_(str(round(res.runtime)) in printed) |
| 405 | |
| 406 | |
| 407 | @pytest.mark.parametrize("missing_value", [5, 100, MAX_VALUE, MAX_VALUE + 1]) |
nothing calls this directly
no test coverage detected