Skip to content

Commit

Permalink
Format command-line included global config files on load so that envi…
Browse files Browse the repository at this point in the history
…ronment variables can be used in said config files
  • Loading branch information
michaelboulton committed Sep 21, 2018
1 parent ebd4d1d commit fbece9f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
17 changes: 16 additions & 1 deletion tavern/testutils/pytesthook.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
import logging
import itertools
import copy
import py
import os

import py
import attr
from _pytest._code.code import FormattedExcinfo
from _pytest import fixtures
import pytest
import yaml
from future.utils import raise_from
from box import Box

from tavern.plugins import load_plugins
from tavern.core import run_test
Expand Down Expand Up @@ -347,6 +349,19 @@ def _parse_arguments(self):
all_paths = ini_global_cfg_paths + cmdline_global_cfg_paths
global_cfg = load_global_config(all_paths)

try:
loaded_variables = global_cfg["variables"]
except KeyError:
logger.debug("Nothing to format in global config files")
else:
tavern_box = Box({
"tavern": {
"env_vars": dict(os.environ),
}
})

global_cfg["variables"] = format_keys(loaded_variables, tavern_box)

if self.config.getini("tavern-strict") is not None:
strict = self.config.getini("tavern-strict")
if isinstance(strict, list):
Expand Down
1 change: 0 additions & 1 deletion tests/integration/test_stream.tavern.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,3 @@ stages:
stream: True
response:
status_code: 200

0 comments on commit fbece9f

Please sign in to comment.