From 33885413f4af5ea01edce65cb26fc4e25a6f15b8 Mon Sep 17 00:00:00 2001 From: santosh Date: Tue, 10 Oct 2017 15:04:56 +0530 Subject: [PATCH] Fixes the issue for count mismatch with rerun plugin --- CHANGES.rst | 5 +++++ pytest_progress.py | 47 ++++++++++++++++++++++++++++------------- test_progress_report.py | 17 +++++++++------ version.txt | 2 +- 4 files changed, 48 insertions(+), 23 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 18f280c..87bd1c1 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -27,3 +27,8 @@ Release Notes * Fixes for typo error in project name * Show failure details for rerun cases as well + + +**1.2.1 (2017-10-10)** + +* Fixes issues with count mismatch with rerun plugin diff --git a/pytest_progress.py b/pytest_progress.py index 6a19762..251ddb2 100644 --- a/pytest_progress.py +++ b/pytest_progress.py @@ -62,25 +62,47 @@ def __init__(self, reporter): self.rerun_count = 0 - def append_rerun(self): - self.rerun_count = self.rerun_count + 1 + def append_rerun(self, report): + if report.failed: + self.append_failure(report) - def append_pass(self): - self.pass_count = self.pass_count + 1 - self.tests_taken = self.tests_taken + 1 + if report.when == "call" and report.rerun: # ignore setup/teardown + self.rerun_count = self.rerun_count + 1 + elif report.skipped: + self.append_skipped(report) - def append_failure(self, report): + + def append_pass(self, report): if hasattr(report, "wasxfail"): self.xpass_count = self.xpass_count + 1 self.tests_taken = self.tests_taken + 1 else: - self.fail_count = self.fail_count + 1 + self.pass_count = self.pass_count + 1 self.tests_taken = self.tests_taken + 1 + if hasattr(report, 'rerun'): + if report.rerun: + self.rerun_count = self.rerun_count + 1 + + + def append_failure(self, report): + + if report.when == "call": + if hasattr(report, "wasxfail"): + self.xpass_count = self.xpass_count + 1 + self.tests_taken = self.tests_taken + 1 + + else: + self.fail_count = self.fail_count + 1 + self.tests_taken = self.tests_taken + 1 + + else: + self.append_error() + def append_error(self): @@ -103,18 +125,13 @@ def append_skipped(self, report): def pytest_report_teststatus(self, report): """ Called after every test for test case status""" if report.passed and report.when == "call": - self.append_pass() + self.append_pass(report) elif hasattr(report, 'rerun'): - if report.when == "call" and report.rerun: # ignore setup/teardown - self.append_rerun() + self.append_rerun(report) elif report.failed: - if report.when == "call": - self.append_failure(report) - - else: - self.append_error() + self.append_failure(report) elif report.skipped: self.append_skipped(report) diff --git a/test_progress_report.py b/test_progress_report.py index d90c169..0ece3df 100644 --- a/test_progress_report.py +++ b/test_progress_report.py @@ -1,15 +1,15 @@ import pytest - +import random class Test_Progress_Report(object): - - + + def test_progress_report_01(self): assert True - - - @pytest.mark.xfail(reason="passed Simply") + + + @pytest.mark.xfail(reason="passed Simply") def test_progress_report_02(self): assert True @@ -25,6 +25,9 @@ def test_progress_report_04(self): def test_progress_report_05(self): - assert True is False + assert False + + def test_progress_report_06(self): + assert random.choice([True, False]) diff --git a/version.txt b/version.txt index 26aaba0..6085e94 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.2.0 +1.2.1