Exemple #1
0
    def testtextoutput1simpleatom(self):
        stream = framing.stream(1)
        val = list(framing.createtextoutputframe(stream, 1,
                                                 [(b'foo', [], [])]))

        self.assertEqual(val, [
            ffs(b'1 1 stream-begin text-output 0 '
                b"cbor:[{b'msg': b'foo'}]"),
        ])
Exemple #2
0
    def testtextoutput1label(self):
        stream = framing.stream(1)
        val = list(framing.createtextoutputframe(stream, 1, [
            (b'foo', [], [b'label']),
        ]))

        self.assertEqual(val, [
            ffs(b'1 1 stream-begin text-output 0 '
                b"cbor:[{b'msg': b'foo', b'labels': [b'label']}]")
        ])
Exemple #3
0
    def testtextoutput2arg(self):
        stream = framing.stream(1)
        val = list(framing.createtextoutputframe(stream, 1, [
            (b'foo %s %s', [b'val', b'value'], []),
        ]))

        self.assertEqual(val, [
            ffs(b'1 1 stream-begin text-output 0 '
                b"cbor:[{b'msg': b'foo %s %s', b'args': [b'val', b'value']}]")
        ])
Exemple #4
0
 def testtextoutputlabelbytes(self):
     with self.assertRaisesRegex(ValueError, 'must use bytes for labels'):
         list(
             framing.createtextoutputframe(
                 None, 1, [(b'foo', [], [b'foo'.decode('ascii')])]))
Exemple #5
0
 def testtextoutputformattingstringtype(self):
     """Formatting string must be bytes."""
     with self.assertRaisesRegex(ValueError, 'must use bytes formatting '):
         list(
             framing.createtextoutputframe(
                 None, 1, [(b'foo'.decode('ascii'), [], [])]))