Esempio n. 1
0
    def test_parse_addr(self):
        """Testing util.network: parse_addr() basic behaviour"""
        assert network.parse_addr("127.0.0.1:12", resolve=False) == \
            ("127.0.0.1", 12, socket.AF_INET)

        assert network.parse_addr("127.0.0.1", defport=12) == \
            ("127.0.0.1", 12, socket.AF_INET)

        assert network.parse_addr("[::1]:12") == \
            ("::1", 12, socket.AF_INET6)

        assert network.parse_addr("[::1]", defport=12) == \
            ("::1", 12, socket.AF_INET6)

        assert network.parse_addr("localhost:12") in [
            ("::1", 12, socket.AF_INET6), ("127.0.0.1", 12, socket.AF_INET)]
Esempio n. 2
0
    def test_parse_addr(self):
        """Testing util.network: parse_addr() basic behaviour"""
        assert network.parse_addr("127.0.0.1:12", resolve=False) == \
            ("127.0.0.1", 12, socket.AF_INET)

        assert network.parse_addr("127.0.0.1", defport=12) == \
            ("127.0.0.1", 12, socket.AF_INET)

        assert network.parse_addr("[::1]:12") == \
            ("::1", 12, socket.AF_INET6)

        assert network.parse_addr("[::1]", defport=12) == \
            ("::1", 12, socket.AF_INET6)

        assert network.parse_addr("localhost:12") in [
            ("::1", 12, socket.AF_INET6), ("127.0.0.1", 12, socket.AF_INET)
        ]
Esempio n. 3
0
 def test_parse_addr_fail_resolve(self):
     """Testing util.network: parse_addr() cannot resolve"""
     _mocked_getaddrinfo = lambda *a, **kw: None
     with self.assertRaises(ValueError):
         network.socket.getaddrinfo = _mocked_getaddrinfo
         network.parse_addr("127.0.0.1:12")
Esempio n. 4
0
 def test_parse_addr_fail(self):
     """Testing util.network: parse_addr() bad address"""
     with self.assertRaises(ValueError):
         network.parse_addr("300.0.0.1:12")
Esempio n. 5
0
 def test_parse_addr_empty(self):
     """Testing util.network: parse_addr() empty address"""
     with self.assertRaises(ValueError):
         network.parse_addr("")
Esempio n. 6
0
 def test_parse_addr_fail_resolve(self):
     """Testing util.network: parse_addr() cannot resolve"""
     _mocked_getaddrinfo = lambda *a, **kw: None
     with self.assertRaises(ValueError):
         network.socket.getaddrinfo = _mocked_getaddrinfo
         network.parse_addr("127.0.0.1:12")
Esempio n. 7
0
 def test_parse_addr_fail(self):
     """Testing util.network: parse_addr() bad address"""
     with self.assertRaises(ValueError):
         network.parse_addr("300.0.0.1:12")
Esempio n. 8
0
 def test_parse_addr_empty(self):
     """Testing util.network: parse_addr() empty address"""
     with self.assertRaises(ValueError):
         network.parse_addr("")