diff --git a/.vscode/settings.json b/.vscode/settings.json index 64df35d..eae31c5 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -29,9 +29,11 @@ ], "cSpell.words": [ "autouse", + "capsys", "funcs", "initargs", "inlinehilite", + "ipywidgets", "linenums", "pbar", "pygments", diff --git a/atpbar/presentation/barjupyter.py b/atpbar/presentation/barjupyter.py index 76fe363..247108c 100755 --- a/atpbar/presentation/barjupyter.py +++ b/atpbar/presentation/barjupyter.py @@ -21,7 +21,7 @@ def __init__(self) -> None: def __repr__(self) -> str: return "{}()".format(self.__class__.__name__) - def _present(self) -> None: + def _present(self, report: Report) -> None: self._create_widgets() self._update_widgets() @@ -30,7 +30,7 @@ def _create_widgets(self) -> None: self.container_widget = widgets.VBox() display(self.container_widget) - for taskid in self._new_taskids: + for taskid in self._new_task_ids: report = self._report_dict[taskid] self._create_widget(report) @@ -54,14 +54,14 @@ def _create_widget(self, report: Report) -> None: def _update_widgets(self) -> None: for taskid in ( - self._finishing_taskids + self._active_taskids + self._new_taskids + self._finishing_task_ids + self._active_task_ids + self._new_task_ids ): report = self._report_dict[taskid] self._update_widget(report) self._reorder_widgets(report) - if not self._new_taskids and not self._active_taskids: + if not self._new_task_ids and not self._active_task_ids: self.container_widget = None self.active_box_list[:] = [] self.complete_box_list[:] = [] @@ -74,6 +74,7 @@ def _update_widget(self, report: Report) -> None: percent_fmt = "{:6.2f}%".format(percent) box = self.widget_dict[report["taskid"]][0] + box # to silence not-used warning bar = self.widget_dict[report["taskid"]][1] bar.value = report["done"] @@ -93,7 +94,7 @@ def _update_widget(self, report: Report) -> None: ) def _reorder_widgets(self, report: Report) -> None: - for taskid in self._finishing_taskids: + for taskid in self._finishing_task_ids: box, bar, label = self.widget_dict[taskid] if box in self.active_box_list: self.active_box_list.remove(box) diff --git a/atpbar/presentation/bartty.py b/atpbar/presentation/bartty.py index 5c1ebe9..4febecb 100755 --- a/atpbar/presentation/bartty.py +++ b/atpbar/presentation/bartty.py @@ -28,7 +28,7 @@ def _get_width(self) -> int: except AttributeError: return MINIMUM_TERMINAL_WIDTH - def _present(self) -> None: + def _present(self, report: Report) -> None: self._erase_active_bars() self._compose_just_finished_bars() self._compose_active_bars() @@ -45,13 +45,13 @@ def _write(self, s: str, out: TextIO) -> None: self._draw_active_bars() def _erase_active_bars(self) -> None: - nlines = len(self._active_taskids) + len(self._finishing_taskids) + n_lines = len(self._active_task_ids) + len(self._finishing_task_ids) # must be the same as len(self.active_bars) - if nlines == 0: + if n_lines == 0: return - code = "\033[1G" + "\033[A" * (nlines - 1) + "\033[0J" + code = "\033[1G" + "\033[A" * (n_lines - 1) + "\033[0J" # '\033[1G' move the cursor to the beginning of the line # '\033[A' move the cursor up # '\033[0J' clear from cursor to end of screen @@ -61,13 +61,13 @@ def _erase_active_bars(self) -> None: def _compose_just_finished_bars(self) -> None: self.just_finished_bars = [ - self._compose_bar_from_taskid(i) for i in self._finishing_taskids + self._compose_bar_from_taskid(i) for i in self._finishing_task_ids ] def _compose_active_bars(self) -> None: self.active_bars = [ self._compose_bar_from_taskid(i) - for i in self._active_taskids + self._new_taskids + for i in self._active_task_ids + self._new_task_ids ] def _compose_bar_from_taskid(self, taskid: UUID) -> str: diff --git a/atpbar/presentation/base.py b/atpbar/presentation/base.py index b83b8fa..fbec71b 100755 --- a/atpbar/presentation/base.py +++ b/atpbar/presentation/base.py @@ -23,17 +23,17 @@ def __init__(self) -> None: self.lock = threading.Lock() - self._new_taskids = list[UUID]() - self._active_taskids = list[UUID]() # in order of arrival - self._finishing_taskids = list[UUID]() - self._complete_taskids = list[UUID]() # in order of completion + self._new_task_ids = list[UUID]() + self._active_task_ids = list[UUID]() # in order of arrival + self._finishing_task_ids = list[UUID]() + self._complete_task_ids = list[UUID]() # in order of completion self._report_dict = dict[UUID, Report]() self.interval = 1.0 # [second] self.last_time = time.time() def active(self) -> bool: - if self._active_taskids: + if self._active_task_ids: return True return False @@ -43,63 +43,63 @@ def present(self, report: Report) -> None: return if not self._need_to_present(): return - self._present() + self._present(report) self._update_registry() self.last_time = time.time() @abstractmethod - def _present(self) -> None: + def _present(self, report: Report) -> None: pass def _register_report(self, report: Report) -> bool: taskid = report["taskid"] - if taskid in self._complete_taskids: + if taskid in self._complete_task_ids: return False self._report_dict[taskid] = report - if taskid in self._finishing_taskids: + if taskid in self._finishing_task_ids: return True if report["last"]: try: - self._active_taskids.remove(taskid) + self._active_task_ids.remove(taskid) except ValueError: pass try: - self._new_taskids.remove(taskid) + self._new_task_ids.remove(taskid) except ValueError: pass - self._finishing_taskids.append(taskid) + self._finishing_task_ids.append(taskid) return True - if taskid in self._active_taskids: + if taskid in self._active_task_ids: return True - if taskid in self._new_taskids: + if taskid in self._new_task_ids: return True - self._new_taskids.append(taskid) + self._new_task_ids.append(taskid) return True def _update_registry(self) -> None: - self._active_taskids.extend(self._new_taskids) - del self._new_taskids[:] + self._active_task_ids.extend(self._new_task_ids) + del self._new_task_ids[:] - self._complete_taskids.extend(self._finishing_taskids) - del self._finishing_taskids[:] + self._complete_task_ids.extend(self._finishing_task_ids) + del self._finishing_task_ids[:] def _need_to_present(self) -> bool: - if self._new_taskids: + if self._new_task_ids: return True - if self._finishing_taskids: + if self._finishing_task_ids: return True if time.time() - self.last_time > self.interval: diff --git a/atpbar/presentation/txtprint.py b/atpbar/presentation/txtprint.py index 1dd4bb2..998d60d 100755 --- a/atpbar/presentation/txtprint.py +++ b/atpbar/presentation/txtprint.py @@ -21,14 +21,11 @@ def present(self, report: Report) -> None: if not self._need_to_present_(report): return - self._present_(report) + self._present(report) self.last_time_map[report["taskid"]] = self._time() - - def _present(self) -> None: - pass - def _present_(self, report: Report) -> None: + def _present(self, report: Report) -> None: time_ = time.strftime("%m/%d %H:%M", time.localtime(time.time())) percent = float(report["done"]) / report["total"] if report["total"] > 0 else 1 percent = round(percent * 100, 2) diff --git a/tests/presentation/test_base.py b/tests/presentation/test_base.py index 7a86119..69b95a6 100644 --- a/tests/presentation/test_base.py +++ b/tests/presentation/test_base.py @@ -5,10 +5,11 @@ import pytest from atpbar.presentation.base import Presentation +from atpbar.progress_report import Report class MockProgressBar(Presentation): - def _present(self) -> None: + def _present(self, report: Report) -> None: pass @@ -63,10 +64,10 @@ def test_present(obj: Presentation) -> None: ] param_names = ( "report, " - "initial_new_taskids, initial_active_taskids, " - "initial_finishing_taskids, initial_complete_taskids, " - "expected_new_taskids, expected_active_taskids, " - "expected_finishing_taskids, expected_complete_taskids, " + "initial_new_task_ids, initial_active_task_ids, " + "initial_finishing_task_ids, initial_complete_task_ids, " + "expected_new_task_ids, expected_active_task_ids, " + "expected_finishing_task_ids, expected_complete_task_ids, " "expected_return" ) @@ -75,28 +76,28 @@ def test_present(obj: Presentation) -> None: def test_register_report( # type: ignore obj, report, - initial_new_taskids, - initial_active_taskids, - initial_finishing_taskids, - initial_complete_taskids, - expected_new_taskids, - expected_active_taskids, - expected_finishing_taskids, - expected_complete_taskids, + initial_new_task_ids, + initial_active_task_ids, + initial_finishing_task_ids, + initial_complete_task_ids, + expected_new_task_ids, + expected_active_task_ids, + expected_finishing_task_ids, + expected_complete_task_ids, expected_return, ): - obj._new_taskids[:] = initial_new_taskids - obj._active_taskids[:] = initial_active_taskids - obj._finishing_taskids[:] = initial_finishing_taskids - obj._complete_taskids[:] = initial_complete_taskids + obj._new_task_ids[:] = initial_new_task_ids + obj._active_task_ids[:] = initial_active_task_ids + obj._finishing_task_ids[:] = initial_finishing_task_ids + obj._complete_task_ids[:] = initial_complete_task_ids assert expected_return == obj._register_report(report) - assert expected_new_taskids == obj._new_taskids - assert expected_active_taskids == obj._active_taskids - assert expected_finishing_taskids == obj._finishing_taskids - assert expected_complete_taskids == obj._complete_taskids + assert expected_new_task_ids == obj._new_task_ids + assert expected_active_task_ids == obj._active_task_ids + assert expected_finishing_task_ids == obj._finishing_task_ids + assert expected_complete_task_ids == obj._complete_task_ids params = [ @@ -132,37 +133,37 @@ def test_register_report( # type: ignore ), ] param_names = ( - "initial_new_taskids, initial_active_taskids, " - "initial_finishing_taskids, initial_complete_taskids, " - "expected_new_taskids, expected_active_taskids, " - "expected_finishing_taskids, expected_complete_taskids, " + "initial_new_task_ids, initial_active_task_ids, " + "initial_finishing_task_ids, initial_complete_task_ids, " + "expected_new_task_ids, expected_active_task_ids, " + "expected_finishing_task_ids, expected_complete_task_ids, " ) @pytest.mark.parametrize(param_names, params) def test_update_registry( # type: ignore obj, - initial_new_taskids, - initial_active_taskids, - initial_finishing_taskids, - initial_complete_taskids, - expected_new_taskids, - expected_active_taskids, - expected_finishing_taskids, - expected_complete_taskids, + initial_new_task_ids, + initial_active_task_ids, + initial_finishing_task_ids, + initial_complete_task_ids, + expected_new_task_ids, + expected_active_task_ids, + expected_finishing_task_ids, + expected_complete_task_ids, ): - obj._new_taskids[:] = initial_new_taskids - obj._active_taskids[:] = initial_active_taskids - obj._finishing_taskids[:] = initial_finishing_taskids - obj._complete_taskids[:] = initial_complete_taskids + obj._new_task_ids[:] = initial_new_task_ids + obj._active_task_ids[:] = initial_active_task_ids + obj._finishing_task_ids[:] = initial_finishing_task_ids + obj._complete_task_ids[:] = initial_complete_task_ids obj._update_registry() - assert expected_new_taskids == obj._new_taskids - assert expected_active_taskids == obj._active_taskids - assert expected_finishing_taskids == obj._finishing_taskids - assert expected_complete_taskids == obj._complete_taskids + assert expected_new_task_ids == obj._new_task_ids + assert expected_active_task_ids == obj._active_task_ids + assert expected_finishing_task_ids == obj._finishing_task_ids + assert expected_complete_task_ids == obj._complete_task_ids params = [ @@ -172,7 +173,7 @@ def test_update_registry( # type: ignore pytest.param([], [], 4.0, 2.0, 3.0, False), ] param_names = ( - "new_taskids, finishing_taskids, " "current_time, last_time, interval, expected" + "new_task_ids, finishing_task_ids, " "current_time, last_time, interval, expected" ) @@ -180,16 +181,16 @@ def test_update_registry( # type: ignore def test_need_to_present( # type: ignore obj, mock_time, - new_taskids, - finishing_taskids, + new_task_ids, + finishing_task_ids, current_time, last_time, interval, expected, ): - obj._new_taskids[:] = new_taskids - obj._finishing_taskids[:] = finishing_taskids + obj._new_task_ids[:] = new_task_ids + obj._finishing_task_ids[:] = finishing_task_ids mock_time.time.return_value = current_time obj.last_time = last_time diff --git a/tests/presentation/test_presentation.py b/tests/presentation/test_presentation.py index c3b1b74..cebd5a6 100644 --- a/tests/presentation/test_presentation.py +++ b/tests/presentation/test_presentation.py @@ -24,10 +24,10 @@ if has_jupyter_notebook: classes.append(ProgressBarJupyter) -classe_ids = [c.__name__ for c in classes] +class_ids = [c.__name__ for c in classes] -@pytest.mark.parametrize("Class", classes, ids=classe_ids) +@pytest.mark.parametrize("Class", classes, ids=class_ids) def test_presentation(Class: type[Presentation]) -> None: i = uuid.uuid4() j = uuid.uuid4() @@ -49,7 +49,7 @@ def test_presentation(Class: type[Presentation]) -> None: obj.active() -@pytest.mark.parametrize("Class", classes, ids=classe_ids) +@pytest.mark.parametrize("Class", classes, ids=class_ids) def test_time_track(Class: type[Presentation]) -> None: i = uuid.uuid4() obj = Class() diff --git a/tests/scenarios/conftest.py b/tests/scenarios/conftest.py index fb89c8f..69c2b05 100644 --- a/tests/scenarios/conftest.py +++ b/tests/scenarios/conftest.py @@ -13,18 +13,18 @@ class MockProgressBar(Presentation): def __init__(self) -> None: super().__init__() self.reports = list[Report]() - self.taskids = set[UUID]() - self.nfirsts = 0 - self.nlasts = 0 + self.task_ids = set[UUID]() + self.n_firsts = 0 + self.n_lasts = 0 def __str__(self) -> str: lines = [] - l = "{}: # reports: {}, # taskids: {}, # firsts: {}, # lasts: {}".format( + l = "{}: # reports: {}, # task_ids: {}, # firsts: {}, # lasts: {}".format( self.__class__.__name__, len(self.reports), - len(self.taskids), - self.nfirsts, - self.nlasts, + len(self.task_ids), + self.n_firsts, + self.n_lasts, ) lines.append(l) lines.extend([" {}".format(r) for r in self.reports]) @@ -33,11 +33,11 @@ def __str__(self) -> str: def present(self, report: Report) -> None: super().present(report) self.reports.append(report) - self.taskids.add(report["taskid"]) - self.nfirsts += report["first"] - self.nlasts += report["last"] + self.task_ids.add(report["taskid"]) + self.n_firsts += report["first"] + self.n_lasts += report["last"] - def _present(self) -> None: + def _present(self, report: Report) -> None: pass diff --git a/tests/scenarios/test_last_report.py b/tests/scenarios/test_last_report.py index 77b6370..ae1bf04 100644 --- a/tests/scenarios/test_last_report.py +++ b/tests/scenarios/test_last_report.py @@ -50,9 +50,9 @@ def task_exception(ndones: int, niterations: int) -> None: # progressbar0 = presentations[0] assert nreports_expected == len(progressbar0.reports) - assert 1 == len(progressbar0.taskids) - assert 1 == progressbar0.nfirsts - assert 1 == progressbar0.nlasts + assert 1 == len(progressbar0.task_ids) + assert 1 == progressbar0.n_firsts + assert 1 == progressbar0.n_lasts done_total_list_expected = [(ndones, niterations)] done_total_list_actual = [ (d["done"], d["total"]) for d in progressbar0._report_dict.values() diff --git a/tests/scenarios/test_multiprocessing.py b/tests/scenarios/test_multiprocessing.py index e378fc8..6273659 100644 --- a/tests/scenarios/test_multiprocessing.py +++ b/tests/scenarios/test_multiprocessing.py @@ -92,9 +92,9 @@ def test_multiprocessing_from_loop( assert nreports_expected == len(progressbar0.reports) # one report from `atpbar` in the main thread - assert 1 == progressbar0.nfirsts - assert 1 == progressbar0.nlasts - assert 1 == len(progressbar0.taskids) + assert 1 == progressbar0.n_firsts + assert 1 == progressbar0.n_lasts + assert 1 == len(progressbar0.task_ids) else: if 2 == len(presentations): @@ -103,9 +103,9 @@ def test_multiprocessing_from_loop( assert 0 == len(progressbar1.reports) progressbar0 = presentations[0] - assert ntasks + 1 == len(progressbar0.taskids) - assert ntasks + 1 == progressbar0.nfirsts - assert ntasks + 1 == progressbar0.nlasts + assert ntasks + 1 == len(progressbar0.task_ids) + assert ntasks + 1 == progressbar0.n_firsts + assert ntasks + 1 == progressbar0.n_lasts assert nreports_expected == len(progressbar0.reports) else: @@ -117,9 +117,9 @@ def test_multiprocessing_from_loop( progressbar0 = presentations[0] progressbar1 = presentations[1] - assert ntasks + 1 == len(progressbar0.taskids) + len(progressbar1.taskids) - assert ntasks + 1 == progressbar0.nfirsts + progressbar1.nfirsts - assert ntasks + 1 == progressbar0.nlasts + progressbar1.nlasts + assert ntasks + 1 == len(progressbar0.task_ids) + len(progressbar1.task_ids) + assert ntasks + 1 == progressbar0.n_firsts + progressbar1.n_firsts + assert ntasks + 1 == progressbar0.n_lasts + progressbar1.n_lasts assert nreports_expected == len(progressbar0.reports) + len( progressbar1.reports ) @@ -131,7 +131,7 @@ def test_multiprocessing_from_loop( pass assert npresentations + 1 == len(presentations) progressbar = presentations[-2] - assert 1 == len(progressbar.taskids) - assert 1 == progressbar.nfirsts - assert 1 == progressbar.nlasts + assert 1 == len(progressbar.task_ids) + assert 1 == progressbar.n_firsts + assert 1 == progressbar.n_lasts assert 4 + 1 == len(progressbar.reports) diff --git a/tests/scenarios/test_readme_quick_start.py b/tests/scenarios/test_readme_quick_start.py index 88b5038..a854f0c 100644 --- a/tests/scenarios/test_readme_quick_start.py +++ b/tests/scenarios/test_readme_quick_start.py @@ -31,9 +31,9 @@ def test_one_loop( # progressbar0 = presentations[0] assert nreports_expected == len(progressbar0.reports) - assert 1 == len(progressbar0.taskids) - assert 1 == progressbar0.nfirsts - assert 1 == progressbar0.nlasts + assert 1 == len(progressbar0.task_ids) + assert 1 == progressbar0.n_firsts + assert 1 == progressbar0.n_lasts # progressbar1 = presentations[1] @@ -51,9 +51,9 @@ def test_nested_loops(mock_create_presentation: MockCreatePresentation) -> None: progressbar0 = presentations[0] assert (3 + 1) * 4 + 4 + 1 == len(progressbar0.reports) - assert 5 == len(progressbar0.taskids) - assert 5 == progressbar0.nfirsts - assert 5 == progressbar0.nlasts + assert 5 == len(progressbar0.task_ids) + assert 5 == progressbar0.n_firsts + assert 5 == progressbar0.n_lasts progressbar1 = presentations[1] assert 0 == len(progressbar1.reports) @@ -105,9 +105,9 @@ def test_threading( progressbar0 = presentations[0] assert nreports_expected == len(progressbar0.reports) - assert nthreads == len(progressbar0.taskids) - assert nthreads == progressbar0.nfirsts - assert nthreads == progressbar0.nlasts + assert nthreads == len(progressbar0.task_ids) + assert nthreads == progressbar0.n_firsts + assert nthreads == progressbar0.n_lasts progressbar1 = presentations[1] assert 0 == len(progressbar1.reports) @@ -176,9 +176,9 @@ def test_multiprocessing( progressbar0 = presentations[0] assert nreports_expected == len(progressbar0.reports) - assert ntasks == len(progressbar0.taskids) - assert ntasks == progressbar0.nfirsts - assert ntasks == progressbar0.nlasts + assert ntasks == len(progressbar0.task_ids) + assert ntasks == progressbar0.n_firsts + assert ntasks == progressbar0.n_lasts progressbar1 = presentations[1] assert 0 == len(progressbar1.reports) diff --git a/tests/scenarios/test_threading.py b/tests/scenarios/test_threading.py index b62ce4b..1d60bd2 100644 --- a/tests/scenarios/test_threading.py +++ b/tests/scenarios/test_threading.py @@ -10,25 +10,25 @@ @pytest.mark.parametrize("time_starting_task", [0, 0.01, 0.2]) -@pytest.mark.parametrize("niterations", [[5, 4, 3], [5, 0, 1], [0], [1]]) -@pytest.mark.parametrize("nthreads", [3, 1, 0]) +@pytest.mark.parametrize("n_iterations", [[5, 4, 3], [5, 0, 1], [0], [1]]) +@pytest.mark.parametrize("n_threads", [3, 1, 0]) def test_threading_from_loop( mock_create_presentation: MockCreatePresentation, - nthreads: int, - niterations: list[int], + n_threads: int, + n_iterations: list[int], time_starting_task: float, ) -> None: - # make niterations as long as nthreads. repeat if necessary - niterations = list( + # make n_iterations as long as n_threads. repeat if necessary + n_iterations = list( itertools.chain( - *itertools.repeat(niterations, nthreads // len(niterations) + 1) + *itertools.repeat(n_iterations, n_threads // len(n_iterations) + 1) ) - )[:nthreads] + )[:n_threads] def run_with_threading( - nthreads: int = 3, - niterations: list[int] = [5, 5, 5], + n_threads: int = 3, + n_iterations: list[int] = [5, 5, 5], time_starting_task: float = 0, ) -> None: @@ -50,10 +50,10 @@ def task( # until the progress bar for this loop finish updating. Otherwise, # progress bars from threads are being updated together with the # progress bar for this loop and the `atpbar` will not wait. - for i in atpbar(range(nthreads)): + for i in atpbar(range(n_threads)): name = "thread {}".format(i) - n = niterations[i] + n = n_iterations[i] t = threading.Thread(target=task, args=(n, name, time_starting_task)) t.start() threads.append(t) @@ -68,39 +68,39 @@ def task( flush() - run_with_threading(nthreads, niterations, time_starting_task) + run_with_threading(n_threads, n_iterations, time_starting_task) ## print() ## print(mock_create_presentation) - nreports_expected_from_main = nthreads + 1 - nreports_expected_from_threads = sum(niterations) + nthreads - nreports_expected = nreports_expected_from_main + nreports_expected_from_threads + n_reports_expected_from_main = n_threads + 1 + n_reports_expected_from_threads = sum(n_iterations) + n_threads + n_reports_expected = n_reports_expected_from_main + n_reports_expected_from_threads presentations = mock_create_presentation.presentations - if nreports_expected_from_threads == 0: + if n_reports_expected_from_threads == 0: assert 3 == len(presentations) # when `atpbar` in the main thread # starts and end and when flush() is # called progressbar0 = presentations[0] - assert nreports_expected == len(progressbar0.reports) + assert n_reports_expected == len(progressbar0.reports) # one report from `atpbar` in the main thread - assert 1 == len(progressbar0.taskids) - assert 1 == progressbar0.nfirsts - assert 1 == progressbar0.nlasts + assert 1 == len(progressbar0.task_ids) + assert 1 == progressbar0.n_firsts + assert 1 == progressbar0.n_lasts else: if 2 == len(presentations): progressbar0 = presentations[0] - assert nreports_expected == len(progressbar0.reports) - assert nthreads + 1 == len(progressbar0.taskids) - assert nthreads + 1 == progressbar0.nfirsts - assert nthreads + 1 == progressbar0.nlasts + assert n_reports_expected == len(progressbar0.reports) + assert n_threads + 1 == len(progressbar0.task_ids) + assert n_threads + 1 == progressbar0.n_firsts + assert n_threads + 1 == progressbar0.n_lasts progressbar1 = presentations[1] assert 0 == len(progressbar1.reports) @@ -111,24 +111,26 @@ def task( progressbar0 = presentations[0] progressbar1 = presentations[1] - assert nreports_expected == len(progressbar0.reports) + len( + assert n_reports_expected == len(progressbar0.reports) + len( progressbar1.reports ) - assert nthreads + 1 == len(progressbar0.taskids) + len(progressbar1.taskids) - assert nthreads + 1 == progressbar0.nfirsts + progressbar1.nfirsts - assert nthreads + 1 == progressbar0.nlasts + progressbar1.nlasts + assert n_threads + 1 == len(progressbar0.task_ids) + len( + progressbar1.task_ids + ) + assert n_threads + 1 == progressbar0.n_firsts + progressbar1.n_firsts + assert n_threads + 1 == progressbar0.n_lasts + progressbar1.n_lasts progressbar2 = presentations[2] assert 0 == len(progressbar2.reports) # At this point the pickup shouldn't be owned. Therefore, a new # `atpbar` in the main thread should own it. - npresentations = len(presentations) + n_presentations = len(presentations) for i in atpbar(range(4)): pass - assert npresentations + 1 == len(presentations) + assert n_presentations + 1 == len(presentations) progressbar = presentations[-2] assert 4 + 1 == len(progressbar.reports) - assert 1 == len(progressbar.taskids) - assert 1 == progressbar.nfirsts - assert 1 == progressbar.nlasts + assert 1 == len(progressbar.task_ids) + assert 1 == progressbar.n_firsts + assert 1 == progressbar.n_lasts