subunit: Update to newer upstream version.
authorJelmer Vernooij <jelmer@samba.org>
Mon, 29 Mar 2010 14:25:03 +0000 (16:25 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Mon, 29 Mar 2010 16:05:29 +0000 (18:05 +0200)
lib/README
lib/subunit/python/subunit/run.py
lib/subunit/python/subunit/test_results.py
lib/subunit/python/testtools/matchers.py
lib/subunit/python/testtools/tests/test_matchers.py

index acae62c37872fbeb21ae22c81360245ddfc4b4db..85b7952db8faa0fe06c288385ad05a294a019854 100644 (file)
@@ -1,4 +1,5 @@
 compression - Various compression algorithms (MSZIP, lzxpress)
+dnspython - Python module for working with DNS.
 nss_wrapper - Wrapper for the user and group NSS API allowing the use 
               of other data sources.
 popt - Command-line option parsing library
@@ -6,6 +7,8 @@ replace - Provides replacements for standard (POSIX, C99) functions
           not provided by the host platform.
 socket_wrapper - Wrapper library allowing TCP/IP traffic to be redirected 
                  over Unix domain sockets.
+subunit - Utilities and bindings for working with the Subunit test result 
+          reporting protocol.
 talloc - Hierarchical pool based memory allocator 
 tdb - Simple but fast key/value database library, supporting multiple writers
 torture - Simple unit testing helper library
index e57939fdfa52d8041c549697e7cfdb3cf1c5f11e..01c0b0e9e6b35911b06db3e3a534769a1cbe41de 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python
 #
 # Simple subunit testrunner for python
 # Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007
index 4ccc2aab3517219e70b340042f7f6a34ed81fdb6..6cf84c519e9bc4feccd0ed1cea9c55c893e23cae 100644 (file)
@@ -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)
index 244daceb7f4bd05c9d5cbb4f7dc04fd51ce88809..039c84b7c7e50d7c324ef0131fffbaee554a579d 100644 (file)
@@ -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)
index d5fd8bab3b5843a604faabbcfb169e4cbd3489ff..74b1ebc56ac47b62e1826bf4f60f6ad1ebd8e82a 100644 (file)
@@ -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__)