def c(request): '''Config fixture. Return a config object for easy attribute access''' c = Config('''\ prog: test_loadconfig.py test_version: 0.1.7 conf: | version: $test_version clg: description: Build a full system options: version: short: v action: version version: $prog $test_version args: host: help: Host to build args: nargs: '*' help: extra arguments checkconfig: | import re if re.search('[^\d\w]', '$host'): raise Exception() system_path: /data/salt/system docker__image: reg.gdl/debian ''') # prog and version configs are hardcoded as this test runs in testsuite # Declare PYTHONPATH to use loadconfig package from this project c.project_path = dirname(ppath(__file__)) c.loadconfig_cmd = 'PYTHONPATH={0} {0}/scripts/loadconfig'.format( c.project_path) return c
''' from loadconfig.lib import addpath addpath(__file__) addpath(__file__, parent=True) from loadconfig import Config from loadconfig.lib import (exc, capture_stream, ppath, run, import_file, tempdir, tempfile) from os.path import dirname from pytest import fixture from textwrap import dedent as d # Import main function from loadconfig script. # These extra steps are needed as loadconfig script doesn't end in .py loadconfig_path = '{}/../scripts/loadconfig'.format(ppath(__file__)) loadconfig_module = import_file(loadconfig_path) main = loadconfig_module.main @fixture(scope='module') def c(request): '''Config fixture. Return a config object for easy attribute access''' c = Config('''\ prog: test_loadconfig.py test_version: 0.1.7 conf: | version: $test_version clg: