Skip to content

Commit

Permalink
Merge pull request #25 from Shoobx/subunit-skip
Browse files Browse the repository at this point in the history
Support skipped tests in subunit output
  • Loading branch information
mgedmin committed Apr 30, 2015
2 parents 62fb354 + 48ae154 commit 5630082
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ zope.testrunner Changelog
4.4.8 (unreleased)
==================

- Nothing changed yet.
- Support skipped tests in subunit output


4.4.7 (2015-04-02)
Expand Down
3 changes: 3 additions & 0 deletions src/zope/testrunner/formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,9 @@ def test_success(self, test, seconds):
self._emit_timestamp()
self._subunit.addSuccess(test)

def test_skipped(self, test, reason):
self._subunit.addSkip(test, reason)

def import_errors(self, import_errors):
"""Report test-module import errors (if any)."""
if not import_errors:
Expand Down
33 changes: 33 additions & 0 deletions src/zope/testrunner/tests/testrunner-subunit.txt
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,39 @@ Note that debugging doesn't work when running tests in a subprocess:
]
True


Support skipped tests
---------------------

>>> directory_with_skipped_tests = os.path.join(this_directory,
... 'testrunner-ex-skip')
>>> skip_defaults = [
... '--path', directory_with_skipped_tests,
... '--tests-pattern', '^sample_skipped_tests$',
... ]
>>> sys.argv = ['test']
>>> testrunner.run_internal(
... skip_defaults + ["--subunit", "-t", "TestSkipppedNoLayer"])
time: ...
test: zope.testrunner.layer.UnitTests:setUp
tags: zope:layer
time: ...
successful: zope.testrunner.layer.UnitTests:setUp
tags: zope:layer:zope.testrunner.layer.UnitTests
time: ...
test: sample_skipped_tests.TestSkipppedNoLayer.test_skipped
skip: sample_skipped_tests.TestSkipppedNoLayer.test_skipped [
I'm a skipped test!
]
tags: -zope:layer:zope.testrunner.layer.UnitTests
time: ...
test: zope.testrunner.layer.UnitTests:tearDown
tags: zope:layer
time: ...
successful: zope.testrunner.layer.UnitTests:tearDown
False


And remove the temporary directory:

>>> shutil.rmtree(tmpdir)
Expand Down

0 comments on commit 5630082

Please sign in to comment.