Beispiel #1
0
    def testIPv6(self):
        ipv6 = ipaddress.IPv6Address('2001:db8::1000')
        address = jobs_pb2.NetworkAddress()
        address.address_type = jobs_pb2.NetworkAddress.INET6
        address.packed_bytes = ipv6.packed

        out = io.StringIO()
        pp = pretty.PrettyPrinter(out)
        representer.network_address_pretty(address, pp, cycle=False)

        expected = 'inet6 2001:db8::1000'
        self.assertEqual(out.getvalue(), expected)
Beispiel #2
0
    def testIPv4(self):
        ipv4 = ipaddress.IPv4Address('42.0.255.32')
        address = jobs_pb2.NetworkAddress()
        address.address_type = jobs_pb2.NetworkAddress.INET
        address.packed_bytes = ipv4.packed

        out = io.StringIO()
        pp = pretty.PrettyPrinter(out)
        representer.network_address_pretty(address, pp, cycle=False)

        expected = 'inet 42.0.255.32'
        self.assertEqual(out.getvalue(), expected)