Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Mar 18, 2024
1 parent a1d81db commit e7f5465
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/tqdm_publisher/_subscriber.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from ._publisher import TQDMPublisher


class TQDMProgressSubscriber(TQDMPublisher):
def __init__(self, iterable, on_progress_update: callable, **tqdm_kwargs):
super().__init__(iterable, **tqdm_kwargs)
Expand Down
5 changes: 3 additions & 2 deletions tests/test_publisher.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import time

from tqdm_publisher import TQDMPublisher

import time

def test_initialization():
publisher = TQDMPublisher()
Expand All @@ -21,7 +22,7 @@ def test_callback(identifier, data):

assert "n" in data and "total" in data

all_task_durations_in_seconds = [.1 for _ in range(10)]
all_task_durations_in_seconds = [0.1 for _ in range(10)]

publisher = TQDMPublisher(all_task_durations_in_seconds)

Expand Down
15 changes: 8 additions & 7 deletions tests/test_subscriber.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import time

from tqdm_publisher import TQDMProgressSubscriber

import time


def test_initialization():
publisher = TQDMProgressSubscriber([], on_progress_update = lambda data: print(data))
publisher = TQDMProgressSubscriber([], on_progress_update=lambda data: print(data))
assert len(publisher.callbacks) == 1


Expand All @@ -17,15 +16,17 @@ def test_single_callback_execution():
def test_callback(data):
nonlocal n_callback_executions
n_callback_executions += 1
print('CAllin')
print("CAllin")
assert "progress_bar_id" in data and "format_dict" in data
assert "n" in data["format_dict"] and "total" in data["format_dict"]

all_task_durations_in_seconds = [.1 for _ in range(10)]
publisher = TQDMProgressSubscriber(all_task_durations_in_seconds, on_progress_update=lambda data: test_callback(data))
all_task_durations_in_seconds = [0.1 for _ in range(10)]
publisher = TQDMProgressSubscriber(
all_task_durations_in_seconds, on_progress_update=lambda data: test_callback(data)
)

# Simulate an update to trigger the callback
for duration in publisher:
time.sleep(duration)

assert n_callback_executions == len(all_task_durations_in_seconds)
assert n_callback_executions == len(all_task_durations_in_seconds)

0 comments on commit e7f5465

Please sign in to comment.