def testIsIpValid(self): addresses = ('10.18.1.254', '10.50.25.177', '250.0.0.1', '20.20.25.25') badAddresses = ('192.168.1.256', '10.50.25.1777', '256.0.0.1', '20.20.25.25.25') for address in badAddresses: with self.assertRaises(errors.ConfigNetworkError) as cneContext: IPv4.validateAddress(address) self.assertEqual(cneContext.exception.errCode, errors.ERR_BAD_ADDR) for address in addresses: self.assertEqual(IPv4.validateAddress(address), None)
def testIsIpValid(self): addresses = ('10.18.1.254', '10.50.25.177', '250.0.0.1', '20.20.25.25') badAddresses = ('192.168.1.256', '10.50.25.1777', '256.0.0.1', '20.20.25.25.25') for address in badAddresses: with self.assertRaises(errors.ConfigNetworkError) as cneContext: IPv4.validateAddress(address) self.assertEqual(cneContext.exception.errCode, errors.ERR_BAD_ADDR) for address in addresses: self.assertEqual(IPv4.validateAddress(address), None)
def testIsIpValid(self): addresses = ('10.18.1.254', '10.50.25.177', '250.0.0.1', '20.20.25.25') badAddresses = ( '192.168.1.256', '10.50.25.1777', '256.0.0.1', '20.20.25.25.25', ) for address in badAddresses: with pytest.raises(errors.ConfigNetworkError) as cneContext: IPv4.validateAddress(address) assert cneContext.value.errCode == errors.ERR_BAD_ADDR for address in addresses: assert IPv4.validateAddress(address) is None