Skip to content

Commit

Permalink
Only save failed tests (not skipped) to quarantine (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
bhrutledge authored Nov 13, 2019
1 parent 256beb5 commit d07b5fc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/pytest_quarantine.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class SaveQuarantinePlugin(object):

def pytest_runtest_logreport(self, report):
"""Save the ID of a failed test to the quarantine."""
if not report.passed:
if report.failed:
self.quarantine_ids.add(report.nodeid)

def pytest_terminal_summary(self, terminalreporter):
Expand Down
16 changes: 14 additions & 2 deletions tests/test_quarantine.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def test_save_failing_tests(quarantine_path, testdir, error_failed_passed):
)


def test_no_save_with_passing_tests(testdir):
def test_dont_save_other_outcomes(testdir):
quarantine_path = DEFAULT_QUARANTINE
args = ["--save-quarantine"]

Expand All @@ -113,12 +113,24 @@ def test_no_save_with_passing_tests(testdir):
def test_passed():
assert True
@pytest.mark.skip
def test_skipped():
assert False
@pytest.mark.xfail
def test_xfailed():
assert False
@pytest.mark.xfail
def test_xpassed():
assert True
"""
)

result = testdir.runpytest(*args)

result.assert_outcomes(passed=1)
result.assert_outcomes(passed=1, skipped=1, xpassed=1, xfailed=1)
assert result.ret == EXIT_OK
assert quarantine_path not in result.stdout.str()
assert not testdir.path_exists(quarantine_path)
Expand Down

0 comments on commit d07b5fc

Please sign in to comment.