def test_basic_requests_separate_session(self):

        session = requests.Session()
        request = HttpRequest("GET", "https://bing.com")
        policies = [UserAgentPolicy("myusergant"), RedirectPolicy()]
        transport = RequestsTransport(session=session, session_owner=False)
        with Pipeline(transport, policies=policies) as pipeline:
            response = pipeline.run(request)

        assert transport.session
        assert isinstance(response.http_response.status_code, int)
        transport.close()
        assert transport.session
        transport.session.close()
def test_basic_requests_separate_session(port, http_request):

    session = requests.Session()
    request = http_request("GET",
                           "http://localhost:{}/basic/string".format(port))
    policies = [UserAgentPolicy("myusergant"), RedirectPolicy()]
    transport = RequestsTransport(session=session, session_owner=False)
    with Pipeline(transport, policies=policies) as pipeline:
        response = pipeline.run(request)
        if is_rest(request):
            assert is_rest(response.http_response)

    assert transport.session
    assert isinstance(response.http_response.status_code, int)
    transport.close()
    assert transport.session
    transport.session.close()
def test_close_unopened_transport():
    transport = RequestsTransport()
    transport.close()