diff --git a/doc/source/robot/example.robot b/doc/source/robot/example.robot index ab3c5a6..e158746 100644 --- a/doc/source/robot/example.robot +++ b/doc/source/robot/example.robot @@ -11,7 +11,7 @@ ${MESSAGE} Hello, *** Test Cases *** First Test [Documentation] Thorough and relatively lengthy documentation for the example test case that - ... logs ${MESSAGE} and ${NAD} and ${NAMES}. + ... logs ${MESSAGE} and ${NAD} and ${NAMES}. %{RUNTIME_VAR} [Tags] SWRQT-SOME_RQT ANOTHER-TAG SWRQT-OTHER_RQT SYSRQT-SOME_SYSTEM_RQT Log ${MESSAGE} Log ${NAD} diff --git a/mlx/robot2rst/robot_parser.py b/mlx/robot2rst/robot_parser.py index 5d49040..6c3aaa7 100644 --- a/mlx/robot2rst/robot_parser.py +++ b/mlx/robot2rst/robot_parser.py @@ -1,3 +1,4 @@ +import os import re from collections import namedtuple @@ -66,6 +67,11 @@ def visit_TestCase(self, node): previous_token = token elif element_type == Token.TAGS: tags = [el.value for el in element.tokens if el.type == Token.ARGUMENT] + + for var_name in re.findall(r'%\{(.+?)\}', doc): + if var_name in os.environ: + doc = doc.replace(f'%{{{var_name}}}', os.environ[var_name]) + if self.evaluate_inclusion(tags): self.tests.append(self.TestAttributes(node.name, doc, tags)) diff --git a/tox.ini b/tox.ini index 2862d7f..34fa9ae 100644 --- a/tox.ini +++ b/tox.ini @@ -46,8 +46,11 @@ commands = flake8 mlx setup.py [testenv:sphinx2.4.5] +setenv = + RUNTIME_VAR = Test env variable deps= {[testenv]deps} + setuptools<70 jinja2 == 2.11.3 markupsafe == 1.1.0 docutils == 0.17 @@ -67,6 +70,8 @@ commands= mlx-warnings --config warnings_config.yml --command make -C doc html [testenv:sphinx-latest] +setenv = + RUNTIME_VAR = Test env variable deps= {[testenv]deps} sphinx