2 # Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2014
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 """Subunit test protocol."""
22 samba
.ensure_third_party_module("iso8601", "pyiso8601")
34 def RemoteError(description
=""):
35 return (Exception, Exception(description
), None)
38 class RemotedTestCase(unittest
.TestCase
):
39 """A class to represent test cases run in child processes.
41 Instances of this class are used to provide the Python test API a TestCase
42 that can be printed to the screen, introspected for metadata and so on.
43 However, as they are a simply a memoisation of a test that was actually
44 run in the past by a separate process, they cannot perform any interactive
48 def __eq__ (self
, other
):
50 return self
.__description
== other
.__description
51 except AttributeError:
54 def __init__(self
, description
):
55 """Create a psuedo test case with description description."""
56 self
.__description
= description
58 def error(self
, label
):
59 raise NotImplementedError("%s on RemotedTestCases is not permitted." %
66 self
.error("tearDown")
68 def shortDescription(self
):
69 return self
.__description
72 return "%s" % (self
.__description
,)
75 return "%s (%s)" % (self
.__description
, self
._strclass
())
78 return "<%s description='%s'>" % \
79 (self
._strclass
(), self
.__description
)
81 def run(self
, result
=None):
82 if result
is None: result
= self
.defaultTestResult()
83 result
.startTest(self
)
84 result
.addError(self
, RemoteError("Cannot run RemotedTestCases.\n"))
89 return "%s.%s" % (cls
.__module
__, cls
.__name
__)