File: test_utils.py

package info (click to toggle)
pdm-backend 2.4.5%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,124 kB
  • sloc: python: 2,833; ansic: 21; makefile: 5; sh: 1
file content (27 lines) | stat: -rw-r--r-- 748 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
25
26
27
import os

import pytest

from pdm.backend.utils import expand_vars

is_nt = os.name == "nt"


@pytest.mark.skipif(is_nt, reason="Posix path")
def test_expand_vars_posix(monkeypatch):
    monkeypatch.setenv("FOO", "foo=a")
    monkeypatch.setenv("BAR", "bar")
    root = "/abc/def"

    line = "file:///${PROJECT_ROOT}/${FOO}:${BAR}:${BAZ}"
    assert expand_vars(line, root) == "file:///abc/def/foo%3Da:bar:${BAZ}"


@pytest.mark.skipif(not is_nt, reason="Windows path")
def test_expand_vars_win(monkeypatch):
    monkeypatch.setenv("FOO", "foo=a")
    monkeypatch.setenv("BAR", "bar")
    root = "C:/abc/def"

    line = "file:///${PROJECT_ROOT}/${FOO}:${BAR}:${BAZ}"
    assert expand_vars(line, root) == "file:///C:/abc/def/foo%3Da:bar:${BAZ}"