~ubuntu-branches/debian/jessie/subunit/jessie

« back to all changes in this revision

Viewing changes to python/subunit/tests/test_test_protocol.py

  • Committer: Package Import Robot
  • Author(s): Jelmer Vernooij
  • Date: 2013-10-16 23:05:55 UTC
  • mfrom: (1.1.10) (3.2.14 sid)
  • Revision ID: package-import@ubuntu.com-20131016230555-v73w2d6s0r41rk97
Tags: 0.0.15-2
Remove extra 'done' in debian/rules. Closes: #725635

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
        Python27TestResult,
35
35
        ExtendedTestResult,
36
36
        )
 
37
from testtools.matchers import Contains
37
38
 
38
39
import subunit
39
40
from subunit import _remote_exception_str, _remote_exception_str_chunked
1128
1129
        self.assertEqual(self.SampleTestToIsolate.TEST, False)
1129
1130
 
1130
1131
 
1131
 
class TestTestProtocolClient(unittest.TestCase):
 
1132
class TestTestProtocolClient(TestCase):
1132
1133
 
1133
1134
    def setUp(self):
 
1135
        super(TestTestProtocolClient, self).setUp()
1134
1136
        self.io = BytesIO()
1135
1137
        self.protocol = subunit.TestProtocolClient(self.io)
1136
1138
        self.unicode_test = PlaceHolder(_u('\u2603'))
1191
1193
        """Test addFailure on a TestProtocolClient with details."""
1192
1194
        self.protocol.addFailure(
1193
1195
            self.test, details=self.sample_tb_details)
1194
 
        self.assertEqual(
1195
 
            self.io.getvalue(),
 
1196
        self.assertThat([
1196
1197
            _b(("failure: %s [ multipart\n"
1197
1198
            "Content-Type: text/plain\n"
1198
1199
            "something\n"
1199
1200
            "F\r\nserialised\nform0\r\n"
1200
1201
            "Content-Type: text/x-traceback;charset=utf8,language=python\n"
1201
1202
            "traceback\n" + _remote_exception_str_chunked + ": boo qux\n0\r\n"
1202
 
            "]\n") % self.test.id()))
 
1203
            "]\n") % self.test.id()),
 
1204
            _b(("failure: %s [ multipart\n"
 
1205
            "Content-Type: text/plain\n"
 
1206
            "something\n"
 
1207
            "F\r\nserialised\nform0\r\n"
 
1208
            "Content-Type: text/x-traceback;language=python,charset=utf8\n"
 
1209
            "traceback\n" + _remote_exception_str_chunked + ": boo qux\n0\r\n"
 
1210
            "]\n") % self.test.id())
 
1211
            ],
 
1212
            Contains(self.io.getvalue())),
1203
1213
 
1204
1214
    def test_add_error(self):
1205
1215
        """Test stopTest on a TestProtocolClient."""
1215
1225
        """Test stopTest on a TestProtocolClient with details."""
1216
1226
        self.protocol.addError(
1217
1227
            self.test, details=self.sample_tb_details)
1218
 
        self.assertEqual(
1219
 
            self.io.getvalue(),
 
1228
        self.assertThat([
1220
1229
            _b(("error: %s [ multipart\n"
1221
1230
            "Content-Type: text/plain\n"
1222
1231
            "something\n"
1223
1232
            "F\r\nserialised\nform0\r\n"
1224
1233
            "Content-Type: text/x-traceback;charset=utf8,language=python\n"
1225
1234
            "traceback\n" + _remote_exception_str_chunked + ": boo qux\n0\r\n"
1226
 
            "]\n") % self.test.id()))
 
1235
            "]\n") % self.test.id()),
 
1236
            _b(("error: %s [ multipart\n"
 
1237
            "Content-Type: text/plain\n"
 
1238
            "something\n"
 
1239
            "F\r\nserialised\nform0\r\n"
 
1240
            "Content-Type: text/x-traceback;language=python,charset=utf8\n"
 
1241
            "traceback\n" + _remote_exception_str_chunked + ": boo qux\n0\r\n"
 
1242
            "]\n") % self.test.id()),
 
1243
            ],
 
1244
            Contains(self.io.getvalue())),
1227
1245
 
1228
1246
    def test_add_expected_failure(self):
1229
1247
        """Test addExpectedFailure on a TestProtocolClient."""
1239
1257
        """Test addExpectedFailure on a TestProtocolClient with details."""
1240
1258
        self.protocol.addExpectedFailure(
1241
1259
            self.test, details=self.sample_tb_details)
1242
 
        self.assertEqual(
1243
 
            self.io.getvalue(),
 
1260
        self.assertThat([
1244
1261
            _b(("xfail: %s [ multipart\n"
1245
1262
            "Content-Type: text/plain\n"
1246
1263
            "something\n"
1247
1264
            "F\r\nserialised\nform0\r\n"
1248
1265
            "Content-Type: text/x-traceback;charset=utf8,language=python\n"
1249
1266
            "traceback\n" + _remote_exception_str_chunked + ": boo qux\n0\r\n"
1250
 
            "]\n") % self.test.id()))
1251
 
 
 
1267
            "]\n") % self.test.id()),
 
1268
            _b(("xfail: %s [ multipart\n"
 
1269
            "Content-Type: text/plain\n"
 
1270
            "something\n"
 
1271
            "F\r\nserialised\nform0\r\n"
 
1272
            "Content-Type: text/x-traceback;language=python,charset=utf8\n"
 
1273
            "traceback\n" + _remote_exception_str_chunked + ": boo qux\n0\r\n"
 
1274
            "]\n") % self.test.id()),
 
1275
            ],
 
1276
            Contains(self.io.getvalue())),
1252
1277
 
1253
1278
    def test_add_skip(self):
1254
1279
        """Test addSkip on a TestProtocolClient."""
1324
1349
 
1325
1350
    def test_tags_both(self):
1326
1351
        self.protocol.tags(set(['quux']), set(['bar']))
1327
 
        self.assertEqual(_b("tags: quux -bar\n"), self.io.getvalue())
 
1352
        self.assertThat(
 
1353
            [b"tags: quux -bar\n", b"tags: -bar quux\n"],
 
1354
            Contains(self.io.getvalue()))
1328
1355
 
1329
1356
    def test_tags_gone(self):
1330
1357
        self.protocol.tags(set(), set(['bar']))
1331
1358
        self.assertEqual(_b("tags: -bar\n"), self.io.getvalue())
1332
 
 
1333
 
 
1334
 
def test_suite():
1335
 
    loader = subunit.tests.TestUtil.TestLoader()
1336
 
    result = loader.loadTestsFromName(__name__)
1337
 
    return result