def test_unknown_type(self): with pytest.raises(exceptions.FlowReadException, match="Unknown flow type"): weird_flow = tnetstring.dumps({ "type": "unknown", "version": version.FLOW_FORMAT_VERSION }) for _ in FlowReader(io.BytesIO(weird_flow)).stream(): pass
def test_roundtrip_big_integer(self): i1 = math.factorial(30000) s = tnetstring.dumps(i1) i2 = tnetstring.loads(s) self.assertEqual(i1, i2)
def test_roundtrip_format_unicode(self): for _ in range(500): v = get_random_object() self.assertEqual(v, tnetstring.loads(tnetstring.dumps(v))) self.assertEqual((v, b''), tnetstring.pop(tnetstring.dumps(v)))
def test_roundtrip_format_examples(self): for data, expect in FORMAT_EXAMPLES.items(): self.assertEqual(expect, tnetstring.loads(data)) self.assertEqual( expect, tnetstring.loads(tnetstring.dumps(expect))) self.assertEqual((expect, b''), tnetstring.pop(data))
def test_roundtrip_big_integer(self): i1 = math.factorial(30000) s = tnetstring.dumps(i1) i2 = tnetstring.loads(s) self.assertEqual(i1, i2)
def test_roundtrip_format_unicode(self): for _ in range(500): v = get_random_object() self.assertEqual(v, tnetstring.loads(tnetstring.dumps(v))) self.assertEqual((v, b''), tnetstring.pop(tnetstring.dumps(v)))
def test_roundtrip_format_examples(self): for data, expect in FORMAT_EXAMPLES.items(): self.assertEqual(expect, tnetstring.loads(data)) self.assertEqual( expect, tnetstring.loads(tnetstring.dumps(expect))) self.assertEqual((expect, b''), tnetstring.pop(data))