Skip to content

Commit

Permalink
[tests] Allow to specify plugin options
Browse files Browse the repository at this point in the history
  • Loading branch information
buglloc committed Apr 3, 2017
1 parent 3885d13 commit a0a01d6
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions tests/plugins/test_simply.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,27 @@ def test_from_config():
'Plugin "{}" should have at least one simple test config with false positive'.format(plugin))


def yoda_provider(plugin):
def parse_plugin_options(config_path):
with open(config_path, 'r') as f:
config_line = f.readline()
if config_line.startswith('# Options: '):
return json.loads(config_line[10:])
return None


def yoda_provider(plugin, plugin_options=None):
config = Config(
allow_includes=False,
plugins=[plugin]
)
if plugin_options:
config.set_for(plugin, plugin_options)
return Gixy(config=config)


def check_configuration(plugin, config_path, test_config):
with yoda_provider(plugin) as yoda:
plugin_options = parse_plugin_options(config_path)
with yoda_provider(plugin, plugin_options) as yoda:
yoda.audit(config_path)
results = RawFormatter().format(yoda)

Expand Down

0 comments on commit a0a01d6

Please sign in to comment.