s4:gensec/gssapi: use gensec_gssapi_max_{input,wrapped}_size() for all backends
[Samba.git] / python / samba / subunit / __init__.py
blobcdc593398a005ec9a9d81f2b248e360c1ef61dde
1 # Subunit handling
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."""
20 import samba
22 samba.ensure_third_party_module("iso8601", "pyiso8601")
23 import iso8601
25 import unittest
28 PROGRESS_SET = 0
29 PROGRESS_CUR = 1
30 PROGRESS_PUSH = 2
31 PROGRESS_POP = 3
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
45 actions.
46 """
48 def __eq__ (self, other):
49 try:
50 return self.__description == other.__description
51 except AttributeError:
52 return False
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." %
60 label)
62 def setUp(self):
63 self.error("setUp")
65 def tearDown(self):
66 self.error("tearDown")
68 def shortDescription(self):
69 return self.__description
71 def id(self):
72 return "%s" % (self.__description,)
74 def __str__(self):
75 return "%s (%s)" % (self.__description, self._strclass())
77 def __repr__(self):
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"))
85 result.stopTest(self)
87 def _strclass(self):
88 cls = self.__class__
89 return "%s.%s" % (cls.__module__, cls.__name__)