From 300b1dc0efe0814c052800bc482a239ce293ade6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=20=C4=8Cerm=C3=A1k?= Date: Mon, 28 May 2018 00:31:55 +0200 Subject: [PATCH] [testsuite] Testsuite injects config file values into its namespace --- tests/doc.md | 10 +++++++--- tests/system_tests.py | 6 ++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/tests/doc.md b/tests/doc.md index 5f9c887a..c1c374b3 100644 --- a/tests/doc.md +++ b/tests/doc.md @@ -220,10 +220,14 @@ following a `$` with variables either defined in this class alongside (like configuration file. Please note that defining a variable with the same name as a variable in the suite's configuration file will result in an error (otherwise one of the variables would take precedence leading to unexpected results). The -substitution of values is performed using the template module from Python's -string library via `safe_substitute`. +variables defined in the test suites configuration file are also available in +the `system_tests` namespace. In the above example it would be therefore +possible to access `abort_exit_value` via `system_tests.abort_exit_value` +(please be aware that all values will be strings though). -In the above example the command would thus expand to: +The substitution of values is performed using the template module from Python's +string library via `safe_substitute`. In the above example the command would +thus expand to: ``` shell /path/to/the/dir/build/bin/binary -c /path/to/the/dir/conf/main.cfg -i invalid_input_file ``` diff --git a/tests/system_tests.py b/tests/system_tests.py index 8dc30d01..67b57f21 100644 --- a/tests/system_tests.py +++ b/tests/system_tests.py @@ -177,6 +177,12 @@ def configure_suite(config_file): ) _parameters[key] = abs_path + for key in _parameters: + if key in globals(): + raise ValueError("Variable name {!s} already used.") + + globals()[key] = _parameters[key] + class FileDecoratorBase(object): """