File: test_env.py

package info (click to toggle)
easyprocess 1.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 240 kB
  • sloc: python: 774; sh: 25; makefile: 3
file content (20 lines) | stat: -rw-r--r-- 434 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
import json
import sys

from easyprocess import EasyProcess

python = sys.executable


def pass_env(e):
    prog = "import os,json;print(json.dumps(dict(os.environ)))"
    s = EasyProcess([python, "-c", prog], env=e).call().stdout
    return json.loads(s)


def test_env():
    assert len(pass_env(None)) > 0
    e = pass_env(None)
    assert pass_env(e).get("FOO") is None
    e["FOO"] = "2"
    assert pass_env(e).get("FOO") == "2"