Skip to content

Commit

Permalink
Fixes the issue for count mismatch with rerun plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
ssrikanta committed Oct 10, 2017
1 parent 9081f07 commit 3388541
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 23 deletions.
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
47 changes: 32 additions & 15 deletions pytest_progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand All @@ -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)
Expand Down
17 changes: 10 additions & 7 deletions test_progress_report.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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])

2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.2.0
1.2.1

0 comments on commit 3388541

Please sign in to comment.