Skip to content

Commit

Permalink
xunit/add-block-for-each-test-failed-at-setupclass (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
z00sts authored Apr 10, 2018
1 parent 08c249e commit 5b85502
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 8 deletions.
14 changes: 9 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
## 0.4.6

- XUnit plugin now also drops separate block to XUnit report for all single tests (even if failed on setUpClass)

## 0.4.5

- NoseId plugin also collects tests failed during setup test suite
- NoseId plugin also collects all tests of failed on setup TestSuites

## 0.4.4

- Add 'lode_runner.plugins.Suppressor' plugin. Allows suppress any exceptions in tearDown-methods
- Add `lode_runner.plugins.Suppressor` plugin. Allows suppress any exceptions in tearDown-methods

- Add optional parameter '--xunit-dump-suite-output'. If enabled drops TestSuite-level sysout/syserr to XUnit report.
- Add optional parameter `--xunit-dump-suite-output`. If enabled drops TestSuite-level sysout/syserr to XUnit report.

## 0.4.3

- Add XUnit plugin 'lode_runner.plugins.ClassSkipper'. Allows skip TestClasses with no setUpClass calls
- Add XUnit plugin `lode_runner.plugins.ClassSkipper`. Allows skip TestClasses with no setUpClass calls

## 0.4.2

- Skip 'nose.multiprocess' testcases dirung merging xml files
- Skip `nose.multiprocess` testcases during merging xml files

## 0.4.1

Expand Down
12 changes: 10 additions & 2 deletions lode_runner/lode_merge_xunit.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,13 @@ def modify_suite(suite, testcase, value):
for testcase in suite:
if "nose.plugins.multiprocess" in testcase.get("classname", ""):
continue

candidates = base_root.findall(xpath % testcase.get('classname'))
matching_testcase = next(t for t in candidates if t.get('name') == testcase.get('name'))
try:
matching_testcase = next(t for t in candidates if t.get('name') == testcase.get('name'))
except StopIteration:
matching_testcase = None

if matching_testcase is not None:
modify_suite(base_root, matching_testcase, -1)
base_root.remove(matching_testcase)
Expand All @@ -47,7 +52,9 @@ def modify_suite(suite, testcase, value):

return base_root

get_roots = lambda reports: [ElementTree.parse(r).getroot() for r in reports]

def get_roots(reports):
return [ElementTree.parse(r).getroot() for r in reports]


def merge_reports(reports, output):
Expand All @@ -63,5 +70,6 @@ def main():

merge_reports(reports, output)


if __name__ == "__main__":
main()
19 changes: 19 additions & 0 deletions lode_runner/plugins/xunit.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from lode_runner.plugins import force_unicode_decorator

from nose.suite import ContextSuite
from nose.plugins.xunit import Xunit as NoseXunit, force_unicode
from nose.plugins.base import Plugin

Expand Down Expand Up @@ -86,6 +87,24 @@ def stopContext(self, context):
self._dump_suite_output()
super(Xunit, self).stopContext(context)

def _get_tests_list(self, test):
"""Get separate tests list if `test` is ContextSuite"""
if isinstance(test, ContextSuite):
res = []
for t in test._tests:
res += self._get_tests_list(t)
return res

return [test]

def addError(self, test, err, capt=None):
for t in self._get_tests_list(test):
super(Xunit, self).addError(t, err, capt)

def addFailure(self, test, err, capt=None, tb_info=None):
for t in self._get_tests_list(test):
super(Xunit, self).addFailure(t, err, capt, tb_info)

def report(self, stream):
"""Writes an Xunit-formatted XML file
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
setup(
name='lode_runner',
url='https://github.com/2gis/lode_runner',
version='0.4.5',
version='0.4.6',
description='Nosetests runner plugins package',
long_description='',
author='Igor Pavlov',
Expand Down

0 comments on commit 5b85502

Please sign in to comment.