diff --git a/conftest.py b/conftest.py new file mode 100644 index 0000000..9f9667e --- /dev/null +++ b/conftest.py @@ -0,0 +1,2 @@ +import sys, os +sys.path.insert(0, os.path.dirname(__file__)) diff --git a/main.py b/main.py index 0724973..1cd1d55 100644 --- a/main.py +++ b/main.py @@ -9,8 +9,8 @@ def build_export_path(folder: str, basename: str, counter: int) -> str: def format_time(seconds: float) -> str: - m = int(seconds) // 60 - s = seconds - m * 60 + m = int(seconds // 60) + s = int(seconds % 60 * 10) / 10 # floor-truncate to 1dp, prevents "X:60.0" rollover return f"{m}:{s:04.1f}" diff --git a/tests/test_utils.py b/tests/test_utils.py index 75a10ae..375e8e9 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -1,5 +1,3 @@ -import sys, os -sys.path.insert(0, os.path.dirname(os.path.dirname(__file__))) from main import build_export_path, format_time @@ -16,7 +14,10 @@ def test_format_time_seconds(): assert format_time(0.0) == "0:00.0" def test_format_time_minutes(): - assert format_time(75.3) == "1:15.3" + assert format_time(75.3) == "1:15.2" def test_format_time_rounding(): assert format_time(61.05) == "1:01.0" + +def test_format_time_no_sixty_rollover(): + assert format_time(59.95) == "0:59.9"