File: test_recover_null.py

package info (click to toggle)
python-expandvars 1.1.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 360 kB
  • sloc: python: 656; makefile: 3
file content (18 lines) | stat: -rw-r--r-- 579 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# -*- coding: utf-8 -*-

import importlib
from os import environ as env
from unittest.mock import patch

import expandvars


@patch.dict(env, {"EXPANDVARS_RECOVER_NULL": "foo", "BAR": "bar"}, clear=True)
def test_strict_parsing_recover_null():
    importlib.reload(expandvars)

    assert expandvars.expandvars("${FOO:?}:${BAR?}") == "foo:bar"
    assert expandvars.expandvars("${FOO:?custom err}:${BAR?custom err}") == "foo:bar"

    assert expandvars.expandvars("$FOO$BAR", nounset=True) == "foobar"
    assert expandvars.expandvars("${FOO}:${BAR}", nounset=True) == "foo:bar"