From c85561293399c8f386a9da7871f0c593bde7506c Mon Sep 17 00:00:00 2001 From: anibalinn Date: Fri, 9 Aug 2024 19:20:34 -0300 Subject: [PATCH] Fixing issue with progress bar when there are no scenarios to run --- CHANGES.rst | 2 +- behavex/progress_bar.py | 8 ++++++-- setup.py | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 4b52bd5..69efb46 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,7 +1,7 @@ Version History =============================================================================== -Version: 3.2.12 +Version: 3.2.13 ------------------------------------------------------------------------------- ENHANCEMENTS: diff --git a/behavex/progress_bar.py b/behavex/progress_bar.py index 2d2d755..aa0a548 100644 --- a/behavex/progress_bar.py +++ b/behavex/progress_bar.py @@ -26,8 +26,12 @@ def finish(self, print_if_total_reached=False): def _print_progress_bar(self, new_line=False): prefix = f"{self.prefix}: " if self.prefix else "" - percent = 100 * (self.current_iteration / float(self.total)) - filled_length = int(self.bar_length * self.current_iteration // self.total) + if self.total == 0: + percent = 100 + filled_length = int(self.bar_length) + else: + percent = 100 * (self.current_iteration / float(self.total)) + filled_length = int(self.bar_length * self.current_iteration // self.total) bar = '█' * filled_length + '-' * (self.bar_length - filled_length) elapsed_time = time.time() - self.start_time elapsed_formatted = time.strftime("%M:%S", time.gmtime(elapsed_time)) diff --git a/setup.py b/setup.py index 7770b89..5d8d437 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ setup( name='behavex', - version='3.2.12', + version='3.2.13', python_requires='>=3.5', author='Hernan Rey', author_email='behavex_users@googlegroups.com',