Passed
Push — master ( 895128...fcc2df )
by Fabien
01:21
created

test_envtpl.test_envtpl()   A

Complexity

Conditions 3

Size

Total Lines 10
Code Lines 10

Duplication

Lines 10
Ratio 100 %

Importance

Changes 0
Metric Value
eloc 10
dl 10
loc 10
rs 9.9
c 0
b 0
f 0
cc 3
nop 0
1
import os
2
import pytest
3
from opinionated_configparser import render_string
4
from opinionated_configparser import OpinionatedConfigParser
5
6
7
TEST_DICT1 = {
8
    "section1": {
9
        "key1": "value1{{ENV_VAR}}",
10
    }
11
}
12
13
14 View Code Duplication
def test_envtpl():
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
15
    if "ENV_VAR" in os.environ:
16
        del os.environ["ENV_VAR"]
17
    x = OpinionatedConfigParser(use_envtpl=True)
18
    x.read_dict(TEST_DICT1)
19
    try:
20
        render_string("foo")
21
    except Exception:
22
        pytest.skip("envtpl support missing => skipping")
23
    assert x.get("section1", "key1") == "value1"
24
25
26 View Code Duplication
def test_envtpl2():
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
27
    os.environ["ENV_VAR"] = "foo"
28
    x = OpinionatedConfigParser(use_envtpl=True)
29
    x.read_dict(TEST_DICT1)
30
    try:
31
        render_string("foo")
32
    except Exception:
33
        pytest.skip("envtpl support missing => skipping")
34
    assert x.get("section1", "key1") == "value1foo"
35
    del os.environ["ENV_VAR"]
36