Ejemplo n.º 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'}]"),
        ])
Ejemplo n.º 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']}]")
        ])
Ejemplo n.º 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']}]")
        ])
Ejemplo n.º 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')])]))
Ejemplo n.º 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'), [], [])]))