Home / Class/ TestGetEnvironProxies Class — requests Architecture

TestGetEnvironProxies Class — requests Architecture

Architecture documentation for the TestGetEnvironProxies class in test_utils.py from the requests codebase.

Entity Profile

Dependency Diagram

graph TD
  7288cae5_35cb_e577_a01c_d2e23352eaae["TestGetEnvironProxies"]
  5828793e_be5b_8952_37f1_338fd4634a1a["test_utils.py"]
  7288cae5_35cb_e577_a01c_d2e23352eaae -->|defined in| 5828793e_be5b_8952_37f1_338fd4634a1a
  feb2173d_6291_d991_3519_829c91899928["no_proxy()"]
  7288cae5_35cb_e577_a01c_d2e23352eaae -->|method| feb2173d_6291_d991_3519_829c91899928
  dafa5b87_92e4_e65e_c41d_30a91d8f880e["test_bypass()"]
  7288cae5_35cb_e577_a01c_d2e23352eaae -->|method| dafa5b87_92e4_e65e_c41d_30a91d8f880e
  bae58b59_570b_14d9_2830_e3fa0823c718["test_not_bypass()"]
  7288cae5_35cb_e577_a01c_d2e23352eaae -->|method| bae58b59_570b_14d9_2830_e3fa0823c718
  d0fed457_c9ca_0679_54a2_41f6f13c249c["test_bypass_no_proxy_keyword()"]
  7288cae5_35cb_e577_a01c_d2e23352eaae -->|method| d0fed457_c9ca_0679_54a2_41f6f13c249c
  92a87f4f_633c_a389_7d28_52e46084ea5e["test_not_bypass_no_proxy_keyword()"]
  7288cae5_35cb_e577_a01c_d2e23352eaae -->|method| 92a87f4f_633c_a389_7d28_52e46084ea5e

Relationship Graph

Source Code

tests/test_utils.py lines 210–272

class TestGetEnvironProxies:
    """Ensures that IP addresses are correctly matches with ranges
    in no_proxy variable.
    """

    @pytest.fixture(autouse=True, params=["no_proxy", "NO_PROXY"])
    def no_proxy(self, request, monkeypatch):
        monkeypatch.setenv(
            request.param, "192.168.0.0/24,127.0.0.1,localhost.localdomain,172.16.1.1"
        )

    @pytest.mark.parametrize(
        "url",
        (
            "http://192.168.0.1:5000/",
            "http://192.168.0.1/",
            "http://172.16.1.1/",
            "http://172.16.1.1:5000/",
            "http://localhost.localdomain:5000/v1.0/",
        ),
    )
    def test_bypass(self, url):
        assert get_environ_proxies(url, no_proxy=None) == {}

    @pytest.mark.parametrize(
        "url",
        (
            "http://192.168.1.1:5000/",
            "http://192.168.1.1/",
            "http://www.requests.com/",
        ),
    )
    def test_not_bypass(self, url):
        assert get_environ_proxies(url, no_proxy=None) != {}

    @pytest.mark.parametrize(
        "url",
        (
            "http://192.168.1.1:5000/",
            "http://192.168.1.1/",
            "http://www.requests.com/",
        ),
    )
    def test_bypass_no_proxy_keyword(self, url):
        no_proxy = "192.168.1.1,requests.com"
        assert get_environ_proxies(url, no_proxy=no_proxy) == {}

    @pytest.mark.parametrize(
        "url",
        (
            "http://192.168.0.1:5000/",
            "http://192.168.0.1/",
            "http://172.16.1.1/",
            "http://172.16.1.1:5000/",
            "http://localhost.localdomain:5000/v1.0/",
        ),
    )
    def test_not_bypass_no_proxy_keyword(self, url, monkeypatch):
        # This is testing that the 'no_proxy' argument overrides the
        # environment variable 'no_proxy'
        monkeypatch.setenv("http_proxy", "http://proxy.example.com:3128/")
        no_proxy = "192.168.1.1,requests.com"
        assert get_environ_proxies(url, no_proxy=no_proxy) != {}

Domain

Defined In

Frequently Asked Questions

What is the TestGetEnvironProxies class?
TestGetEnvironProxies is a class in the requests codebase, defined in tests/test_utils.py.
Where is TestGetEnvironProxies defined?
TestGetEnvironProxies is defined in tests/test_utils.py at line 210.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free