|
1 | 1 | import pytest |
2 | | -from nose.tools import assert_equal |
3 | 2 | from openpathsampling.tools import * |
4 | 3 |
|
5 | 4 | import tempfile |
|
16 | 15 |
|
17 | 16 | def test_pretty_print_seconds(): |
18 | 17 | # test the basics with full reporting |
19 | | - assert_equal(pretty_print_seconds(93784), |
20 | | - "1 day 2 hours 3 minutes 4 seconds") |
21 | | - assert_equal(pretty_print_seconds(179990), |
22 | | - "2 days 1 hour 59 minutes 50 seconds") |
23 | | - assert_equal(pretty_print_seconds(31), |
24 | | - "31 seconds") |
| 18 | + assert pretty_print_seconds(93784) == "1 day 2 hours 3 minutes 4 seconds" |
| 19 | + assert (pretty_print_seconds(179990) == |
| 20 | + "2 days 1 hour 59 minutes 50 seconds") |
| 21 | + assert pretty_print_seconds(31) == "31 seconds" |
25 | 22 |
|
26 | 23 | # test positive n_labels (including testing rounding) |
27 | | - assert_equal(pretty_print_seconds(93784, n_labels=2), |
28 | | - "1 day 2 hours") |
29 | | - assert_equal(pretty_print_seconds(179990, n_labels=2), |
30 | | - "2 days 2 hours") |
31 | | - assert_equal(pretty_print_seconds(179990, n_labels=3), |
32 | | - "2 days 2 hours 0 minutes") |
33 | | - assert_equal(pretty_print_seconds(31, n_labels=2), |
34 | | - "31 seconds") |
| 24 | + assert pretty_print_seconds(93784, n_labels=2) == "1 day 2 hours" |
| 25 | + assert pretty_print_seconds(179990, n_labels=2) == "2 days 2 hours" |
| 26 | + assert (pretty_print_seconds(179990, n_labels=3) == |
| 27 | + "2 days 2 hours 0 minutes") |
| 28 | + assert pretty_print_seconds(31, n_labels=2) == "31 seconds" |
35 | 29 |
|
36 | 30 | # test negative n_labels |
37 | | - assert_equal(pretty_print_seconds(93784, n_labels=-1), |
38 | | - "1.09 days") |
39 | | - assert_equal(pretty_print_seconds(93784, n_labels=-2), |
40 | | - "1 day 2.05 hours") |
41 | | - assert_equal(pretty_print_seconds(31, n_labels=-2), |
42 | | - "31 seconds") |
| 31 | + assert pretty_print_seconds(93784, n_labels=-1) == "1.09 days" |
| 32 | + assert pretty_print_seconds(93784, n_labels=-2) == "1 day 2.05 hours" |
| 33 | + assert pretty_print_seconds(31, n_labels=-2) == "31 seconds" |
43 | 34 |
|
44 | 35 | # test separators |
45 | | - assert_equal(pretty_print_seconds(93784, separator=", "), |
46 | | - "1 day, 2 hours, 3 minutes, 4 seconds") |
| 36 | + assert (pretty_print_seconds(93784, separator=", ") == |
| 37 | + "1 day, 2 hours, 3 minutes, 4 seconds") |
47 | 38 |
|
48 | 39 |
|
49 | 40 | def test_progress_string(): |
50 | | - assert_equal(progress_string(0, 100, 10), |
51 | | - "Starting simulation...\nWorking on first step\n") |
52 | | - assert_equal(progress_string(1, 11, 9378.4), |
53 | | - "Running for 2 hours 36 minutes 18 seconds - " |
54 | | - + "9378.40 seconds per step\n" |
55 | | - + "Estimated time remaining: 1 day 2.05 hours\n") |
| 41 | + assert (progress_string(0, 100, 10) == |
| 42 | + "Starting simulation...\nWorking on first step\n") |
| 43 | + assert (progress_string(1, 11, 9378.4) == |
| 44 | + "Running for 2 hours 36 minutes 18 seconds - " |
| 45 | + "9378.40 seconds per step\n" |
| 46 | + "Estimated time remaining: 1 day 2.05 hours\n") |
| 47 | + |
56 | 48 | # Override time_per_step |
57 | | - assert_equal(progress_string(1, 11, 9378.4, 10), |
58 | | - "Running for 2 hours 36 minutes 18 seconds - " |
59 | | - + "10.00 seconds per step\n" |
60 | | - + "Estimated time remaining: 1 minute 40 seconds\n") |
| 49 | + assert (progress_string(1, 11, 9378.4, 10) == |
| 50 | + "Running for 2 hours 36 minutes 18 seconds - " |
| 51 | + "10.00 seconds per step\n" |
| 52 | + "Estimated time remaining: 1 minute 40 seconds\n") |
61 | 53 |
|
62 | 54 |
|
63 | 55 | def test_ensure_file_dne(): |
|
0 commit comments