File: test_session.py

package info (click to toggle)
pdm 2.20.1%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 2,988 kB
  • sloc: python: 24,413; javascript: 34; makefile: 11
file content (24 lines) | stat: -rw-r--r-- 864 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from __future__ import annotations

from typing import TYPE_CHECKING

if TYPE_CHECKING:
    from pdm.project.core import Project


def test_session_sources_all_proxy(project: Project, mocker, monkeypatch):
    monkeypatch.setenv("all_proxy", "http://localhost:8888")
    mock_get_transport = mocker.patch("pdm.models.session._get_transport")

    assert project.environment.session is not None
    transport_args = mock_get_transport.call_args
    assert transport_args is not None
    assert transport_args.kwargs["proxy"].url == "http://localhost:8888"

    monkeypatch.setenv("no_proxy", "pypi.org")
    mock_get_transport.reset_mock()
    del project.environment.session
    assert project.environment.session is not None
    transport_args = mock_get_transport.call_args
    assert transport_args is not None
    assert transport_args.kwargs["proxy"] is None