@contextlib.contextmanager
    def _create_resources(self, name=NETWORK_NAME, cidr=CIDR_1,
                          device_id=DEVICE_ID_1,
                          host_id=COMP_HOST_NAME,
                          expected_failure=False):
        with self.network(name=name) as network:
            with self.subnet(network=network, cidr=cidr) as subnet:
                with self.port(subnet=subnet, cidr=cidr) as port:

                    data = {'port': {portbindings.HOST_ID: host_id,
                                     'device_id': device_id,
                                     'device_owner': DEVICE_OWNER,
                                     'admin_state_up': True}}
                    req = self.new_update_request('ports', data,
                                                  port['port']['id'])
                    yield req.get_response(self.api)
                    if expected_failure:
                        self._create_deviceowner_mock()
        self._delete('ports', port['port']['id'])
        self._delete('networks', network['network']['id'])
Create network, subnet, and port resources for test cases.
dataset/ETHPy150Open openstack/networking-cisco/networking_cisco/tests/unit/ml2/drivers/cisco/nexus/test_cisco_mech.py/TestCiscoPortsV2._create_resources