diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2010-03-29 16:25:03 +0200 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2010-03-29 18:05:29 +0200 |
commit | 082e7f20d7df457c08119eb41fc2f3f8c09ba7ab (patch) | |
tree | 67ad06fcc3125f3091accdc622c6d5c16515addd /lib/subunit/python | |
parent | c87332950043471e52b924f7498b63982ec4302c (diff) | |
download | samba-082e7f20d7df457c08119eb41fc2f3f8c09ba7ab.tar.gz samba-082e7f20d7df457c08119eb41fc2f3f8c09ba7ab.tar.bz2 samba-082e7f20d7df457c08119eb41fc2f3f8c09ba7ab.zip |
subunit: Update to newer upstream version.
Diffstat (limited to 'lib/subunit/python')
-rwxr-xr-x | lib/subunit/python/subunit/run.py | 2 | ||||
-rw-r--r-- | lib/subunit/python/subunit/test_results.py | 4 | ||||
-rw-r--r-- | lib/subunit/python/testtools/matchers.py | 31 | ||||
-rw-r--r-- | lib/subunit/python/testtools/tests/test_matchers.py | 13 |
4 files changed, 47 insertions, 3 deletions
diff --git a/lib/subunit/python/subunit/run.py b/lib/subunit/python/subunit/run.py index e57939fdfa..01c0b0e9e6 100755 --- a/lib/subunit/python/subunit/run.py +++ b/lib/subunit/python/subunit/run.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/python # # Simple subunit testrunner for python # Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007 diff --git a/lib/subunit/python/subunit/test_results.py b/lib/subunit/python/subunit/test_results.py index 4ccc2aab35..6cf84c519e 100644 --- a/lib/subunit/python/subunit/test_results.py +++ b/lib/subunit/python/subunit/test_results.py @@ -83,8 +83,8 @@ class TestResultDecorator(object): def stop(self): return self.decorated.stop() - def tags(self, gone_tags, new_tags): - return self.decorated.time(gone_tags, new_tags) + def tags(self, new_tags, gone_tags): + return self.decorated.time(new_tags, gone_tags) def time(self, a_datetime): return self.decorated.time(a_datetime) diff --git a/lib/subunit/python/testtools/matchers.py b/lib/subunit/python/testtools/matchers.py index 244daceb7f..039c84b7c7 100644 --- a/lib/subunit/python/testtools/matchers.py +++ b/lib/subunit/python/testtools/matchers.py @@ -12,6 +12,7 @@ $ python -c 'import testtools.matchers; print testtools.matchers.__all__' __metaclass__ = type __all__ = [ + 'Annotate', 'DocTestMatches', 'Equals', 'MatchesAll', @@ -249,3 +250,33 @@ class MatchedUnexpectedly: def describe(self): return "%r matches %s" % (self.other, self.matcher) + + +class Annotate: + """Annotates a matcher with a descriptive string. + + Mismatches are then described as '<mismatch>: <annotation>'. + """ + + def __init__(self, annotation, matcher): + self.annotation = annotation + self.matcher = matcher + + def __str__(self): + return 'Annotate(%r, %s)' % (self.annotation, self.matcher) + + def match(self, other): + mismatch = self.matcher.match(other) + if mismatch is not None: + return AnnotatedMismatch(self.annotation, mismatch) + + +class AnnotatedMismatch: + """A mismatch annotated with a descriptive string.""" + + def __init__(self, annotation, mismatch): + self.annotation = annotation + self.mismatch = mismatch + + def describe(self): + return '%s: %s' % (self.mismatch.describe(), self.annotation) diff --git a/lib/subunit/python/testtools/tests/test_matchers.py b/lib/subunit/python/testtools/tests/test_matchers.py index d5fd8bab3b..74b1ebc56a 100644 --- a/lib/subunit/python/testtools/tests/test_matchers.py +++ b/lib/subunit/python/testtools/tests/test_matchers.py @@ -9,6 +9,7 @@ from testtools import ( TestCase, ) from testtools.matchers import ( + Annotate, Equals, DocTestMatches, MatchesAny, @@ -153,6 +154,18 @@ class TestMatchesAllInterface(TestCase, TestMatchersInterface): 1, MatchesAll(NotEquals(1), NotEquals(2)))] +class TestAnnotate(TestCase, TestMatchersInterface): + + matches_matcher = Annotate("foo", Equals(1)) + matches_matches = [1] + matches_mismatches = [2] + + str_examples = [ + ("Annotate('foo', Equals(1))", Annotate("foo", Equals(1)))] + + describe_examples = [("1 != 2: foo", 2, Annotate('foo', Equals(1)))] + + def test_suite(): from unittest import TestLoader return TestLoader().loadTestsFromName(__name__) |