Skip to content

[pull] develop from freqtrade:develop #1300

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
May 21, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test: add format_duration test
  • Loading branch information
xmatthias committed May 20, 2025
commit 947cbdd858f6647f6ba9f2a79bbad83d272c2d8e
14 changes: 12 additions & 2 deletions tests/util/test_formatters.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from freqtrade.util import decimals_per_coin, fmt_coin, round_value
from freqtrade.util.formatters import fmt_coin2
from datetime import timedelta

from freqtrade.util import decimals_per_coin, fmt_coin, fmt_coin2, format_duration, round_value


def test_decimals_per_coin():
Expand Down Expand Up @@ -45,3 +46,12 @@ def test_round_value():
assert round_value(0.1274512123, 5) == "0.12745"
assert round_value(222.2, 3, True) == "222.200"
assert round_value(222.2, 0, True) == "222"


def test_format_duration():
assert format_duration(timedelta(minutes=5)) == "0d 00:05"
assert format_duration(timedelta(minutes=75)) == "0d 01:15"
assert format_duration(timedelta(minutes=1440)) == "1d 00:00"
assert format_duration(timedelta(minutes=1445)) == "1d 00:05"
assert format_duration(timedelta(minutes=11445)) == "7d 22:45"
assert format_duration(timedelta(minutes=101445)) == "70d 10:45"