Tests that calling iteration prints a line about the solution costs and their feasibility.
(ok_small, caplog)
| 76 | |
| 77 | |
| 78 | def test_iteration(ok_small, caplog): |
| 79 | """ |
| 80 | Tests that calling iteration prints a line about the solution costs and |
| 81 | their feasibility. |
| 82 | """ |
| 83 | curr = Solution(ok_small, [[1, 2, 3, 4]]) |
| 84 | cand = Solution(ok_small, [[2, 1], [4, 3]]) |
| 85 | best = Solution(ok_small, [[1, 2], [3, 4]]) |
| 86 | cost_eval = CostEvaluator([20], 6, 6) |
| 87 | |
| 88 | stats = Statistics() |
| 89 | stats.collect(cand, curr, best, cost_eval) |
| 90 | |
| 91 | printer = ProgressPrinter(should_print=True, display_interval=0.0) |
| 92 | |
| 93 | printer.iteration(stats) |
| 94 | out = caplog.text |
| 95 | assert_equal(stats.num_iterations, 1) |
| 96 | |
| 97 | # Statistics about solver progress should be printed. |
| 98 | assert_(str(stats.num_iterations) in out) |
| 99 | assert_(str(round(sum(stats.runtimes))) in out) |
| 100 | |
| 101 | # Statistics about solution costs and their feasibility. |
| 102 | assert_("28408 N" in out) # current |
| 103 | assert_("10012 Y" in out) # candidate |
| 104 | assert_("9725 Y" in out) # best |
| 105 | |
| 106 | |
| 107 | def test_should_print_false_no_output(ok_small, caplog): |
nothing calls this directly
no test coverage detected