Skip to content

Commit 31a871a

Browse files
committed
Merge branch 'release/v3.46.1'
2 parents 5626da3 + 33dd7af commit 31a871a

File tree

5 files changed

+18
-10
lines changed

5 files changed

+18
-10
lines changed

progressbar/__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
long running operations.
2020
'''.strip().split())
2121
__email__ = 'wolph@wol.ph'
22-
__version__ = '3.46.0'
22+
__version__ = '3.46.1'
2323
__license__ = 'BSD'
2424
__copyright__ = 'Copyright 2015 Rick van Hattem (Wolph)'
2525
__url__ = 'https://github.com/WoLpH/python-progressbar'

progressbar/bar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ def percentage(self):
412412

413413
def get_last_update_time(self):
414414
if self._last_update_time:
415-
return datetime.utcfromtimestamp(self._last_update_time)
415+
return datetime.fromtimestamp(self._last_update_time)
416416

417417
def set_last_update_time(self, value):
418418
if value:

progressbar/widgets.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -769,8 +769,11 @@ def __call__(self, progress, data):
769769
context['precision'] = self.precision
770770

771771
try:
772-
context['formatted_value'] = '{value:{width}.{precision}}'.format(
773-
**context)
772+
# Make sure to try and cast the value first, otherwise the
773+
# formatting will generate warnings/errors on newer Python releases
774+
value = float(value)
775+
fmt = '{value:{width}.{precision}}'
776+
context['formatted_value'] = fmt.format(**context)
774777
except (TypeError, ValueError):
775778
if value:
776779
context['formatted_value'] = '{value:{width}}'.format(

tests/conftest.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import logging
55
import freezegun
66
import progressbar
7+
from datetime import datetime
78

89

910
LOG_LEVELS = {
@@ -29,7 +30,12 @@ def small_interval(monkeypatch):
2930

3031
@pytest.fixture(autouse=True)
3132
def sleep_faster(monkeypatch):
32-
freeze_time = freezegun.freeze_time()
33+
# The timezone offset in seconds, add 10 seconds to make sure we don't
34+
# accidently get the wrong hour
35+
offset_seconds = (datetime.now() - datetime.utcnow()).seconds + 10
36+
offset_hours = int(offset_seconds / 3600)
37+
38+
freeze_time = freezegun.freeze_time(tz_offset=offset_hours)
3339
with freeze_time as fake_time:
3440
monkeypatch.setattr('time.sleep', fake_time.tick)
3541
monkeypatch.setattr('timeit.default_timer', time.time)

tests/test_progressbar.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def test_examples(monkeypatch):
1414
pass
1515

1616

17-
@pytest.mark.no_freezegun
17+
@pytest.mark.filterwarnings('ignore:.*maxval.*:DeprecationWarning')
1818
@pytest.mark.parametrize('example', original_examples.examples)
1919
def test_original_examples(example, monkeypatch):
2020
monkeypatch.setattr(progressbar.ProgressBar,
@@ -23,13 +23,12 @@ def test_original_examples(example, monkeypatch):
2323
example()
2424

2525

26-
def test_examples_nullbar(monkeypatch):
26+
@pytest.mark.parametrize('example', examples.examples)
27+
def test_examples_nullbar(monkeypatch, example):
2728
# Patch progressbar to use null bar instead of regular progress bar
2829
monkeypatch.setattr(progressbar, 'ProgressBar', progressbar.NullBar)
29-
3030
assert progressbar.ProgressBar._MINIMUM_UPDATE_INTERVAL < 0.0001
31-
for example in examples.examples:
32-
example()
31+
example()
3332

3433

3534
def test_reuse():

0 commit comments

Comments
 (0)