def test_create_two_subnets_same_cidr_returns_400(self):
gateway_ip_1 = '10.0.0.1'
cidr_1 = '10.0.0.0/24'
gateway_ip_2 = '10.0.0.10'
cidr_2 = '10.0.0.0/24'
with self.network() as network:
with self.subnet(network=network,
gateway_ip=gateway_ip_1,
cidr=cidr_1):
with testtools.ExpectedException(
webob.exc.HTTPClientError) as ctx_manager:
with self.subnet(network=network,
gateway_ip=gateway_ip_2,
cidr=cidr_2):
pass
<! ---------------- Because self.subnet raise the exception, then will exit the with block, so code never can reach at here' ---------------->
self.assertEqual(ctx_manager.exception.code, 400)
There are many test-case like this using 'testtools.ExpectedException' and with invalid status code assertion.
Fix proposed to branch: master /review. openstack. org/28918
Review: https:/