<commit_before># -*- coding: utf-8 -*-
# Licensed to the Apache Software Foundation (ASF) under one or more§
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import os
import socket
import ssl
import sys
from unittest import mock

import requests_mock
from unittest.mock import Mock, patch
from requests.exceptions import ConnectTimeout

import libcloud.common.base
from libcloud.common.base import Connection, CertificateConnection
from libcloud.common.base import Response
from libcloud.common.exceptions import RateLimitReachedError
from libcloud.http import LibcloudBaseConnection
from libcloud.http import LibcloudConnection
from libcloud.http import SignedHTTPSAdapter
from libcloud.test import unittest
from libcloud.utils.py3 import assertRaisesRegex
from libcloud.utils.retry import RETRY_EXCEPTIONS
from libcloud.utils.retry import Retry
from libcloud.utils.retry import RetryForeverOnRateLimitError


class BaseConnectionClassTestCase(unittest.TestCase):
    def setUp(self):
        self.orig_proxy = os.environ.pop("http_proxy", None)

    def tearDown(self):
        if self.orig_proxy:
            os.environ["http_proxy"] = self.orig_proxy
        elif "http_proxy" in os.environ:
            del os.environ["http_proxy"]

        libcloud.common.base.ALLOW_PATH_DOUBLE_SLASHES = False

    def test_parse_proxy_url(self):
        conn = LibcloudBaseConnection()

        proxy_url = "http://127.0.0.1:3128"
        result = conn._parse_proxy_url(proxy_url=proxy_url)
        self.assertEqual(result[0], "http")
        self.assertEqual(result[1], "127.0.0.1")
        self.assertEqual(result[2], 3128)
        self.assertIsNone(result[3])<commit_msg>test/test_connection.py: allow tests to run if https_proxy is set<commit_after># -*- coding: utf-8 -*-
# Licensed to the Apache Software Foundation (ASF) under one or more§
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import os
import socket
import ssl
import sys
from unittest import mock

import requests_mock
from unittest.mock import Mock, patch
from requests.exceptions import ConnectTimeout

import libcloud.common.base
from libcloud.common.base import Connection, CertificateConnection
from libcloud.common.base import Response
from libcloud.common.exceptions import RateLimitReachedError
from libcloud.http import LibcloudBaseConnection
from libcloud.http import LibcloudConnection
from libcloud.http import SignedHTTPSAdapter
from libcloud.test import unittest
from libcloud.utils.py3 import assertRaisesRegex
from libcloud.utils.retry import RETRY_EXCEPTIONS
from libcloud.utils.retry import Retry
from libcloud.utils.retry import RetryForeverOnRateLimitError


class BaseConnectionClassTestCase(unittest.TestCase):
    def setUp(self):
        self.orig_http_proxy = os.environ.pop("http_proxy", None)
        self.orig_https_proxy = os.environ.pop("https_proxy", None)

    def tearDown(self):
        if self.orig_http_proxy:
            os.environ["http_proxy"] = self.orig_http_proxy
        elif "http_proxy" in os.environ:
            del os.environ["http_proxy"]

        if self.orig_https_proxy:
            os.environ["https_proxy"] = self.orig_https_proxy
        elif "https_proxy" in os.environ:
            del os.environ["https_proxy"]

        libcloud.common.base.ALLOW_PATH_DOUBLE_SLASHES = False

    def test_parse_proxy_url(self):
        conn = LibcloudBaseConnection()

        proxy_url = "http://127.0.0.1:3128"
        result = conn._parse_proxy_url(proxy_url=proxy_url)
        self.assertEqual(result[0], "http")
        self.assertEqual(result[1], "127.0.0.1")
        self.assertEqual(result[2], 3128)
        self.assertIsNone(result[3])
{'fraction_non_alphanumeric': 0.07472880674969867, 'fraction_numerical': 0.012053033346725592, 'mean_word_length': 4.096212896622313, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3375845', 'n_tokens_mistral': 1382, 'n_tokens_neox': 1362, 'n_words': 462}