diff --git a/calculate/templates/template_engine.py b/calculate/templates/template_engine.py index 626c2dd..04a106c 100644 --- a/calculate/templates/template_engine.py +++ b/calculate/templates/template_engine.py @@ -1010,7 +1010,6 @@ class CalculateExtension(Extension): переменной datavars.''' lineno = next(self.stream).lineno - # Целового файла больше не будет. target_file = nodes.Const('', lineno=lineno) if self.stream.skip_if('dot'): diff --git a/calculate/variables/datavars.py b/calculate/variables/datavars.py index aad4a93..0902b58 100644 --- a/calculate/variables/datavars.py +++ b/calculate/variables/datavars.py @@ -265,6 +265,9 @@ class Hash: def __contains__(self, key: str) -> bool: return key in self._values + def __str__(self): + return str(self.get_hash()) + class HashType(VariableType): '''Класс, соответствующий типу переменных хэшей.''' diff --git a/run_templates.py b/run_templates.py index 75728db..f43d316 100644 --- a/run_templates.py +++ b/run_templates.py @@ -46,6 +46,7 @@ def main(): dbpkg=args.dbpkg, **group_packages) template_processor.process_template_directories() + datavars.save_variables() if __name__ == "__main__": diff --git a/tests/templates/test_template_executor.py b/tests/templates/test_template_executor.py index 1fbea70..4c47f53 100644 --- a/tests/templates/test_template_executor.py +++ b/tests/templates/test_template_executor.py @@ -3049,6 +3049,7 @@ AttributeError: module 'os' has no attribute 'suspicious_attribute' '/etc/append_join_file_testfiles/logo.png') parameters_object = ParametersContainer({'package': test_package_name, + 'append': 'join', 'source': source_path, 'format': 'raw'}) @@ -3059,6 +3060,7 @@ AttributeError: module 'os' has no attribute 'suspicious_attribute' template_text='', chroot_path=CHROOT_PATH, config_archive_path=CONFIG_ARCHIVE_PATH) + with pytest.raises(TemplateExecutorError): template_executor._append_join_file(template_wrapper) diff --git a/tests/variables/test_datavars.py b/tests/variables/test_datavars.py index 7109fc1..23b4810 100644 --- a/tests/variables/test_datavars.py +++ b/tests/variables/test_datavars.py @@ -1181,11 +1181,11 @@ value = another_value assert datavars.os.ns.var_1 == 'value_1' assert datavars.os.ns.var_2 == 2 - assert 'main' not in datavars.root + assert 'other' not in datavars.root - assert datavars.main.strange_variable == 'weird_value' - assert datavars.main.plain_variable is True - assert 'main' in datavars.root + assert datavars.other.strange_variable == 'weird_value' + assert datavars.other.plain_variable is True + assert 'other' in datavars.root def test_if_a_Datavars_object_is_created_with_path_to_the_variables_with_some_Dependencies_and_then_used_to_get_access_to_the_some_variables_from__the_datavars_object_dynamically_loads_variables_and_retruns_necessary_variables(self): datavars = Datavars( diff --git a/tests/variables/testfiles/variables_0/main/__init__.py b/tests/variables/testfiles/variables_0/main/__init__.py index a8386c9..5b58fb6 100644 --- a/tests/variables/testfiles/variables_0/main/__init__.py +++ b/tests/variables/testfiles/variables_0/main/__init__.py @@ -1,6 +1,6 @@ from calculate.variables.datavars import Namespace, Variable, StringType,\ IntegerType, BooleanType -Variable('strange_variable', source='weird_value', type=StringType) +Variable('old_variable', source='ancient_value', type=StringType) -Variable('plain_variable', source=True, type=BooleanType) +Variable('bool_variable', source=True, type=BooleanType) diff --git a/tests/variables/testfiles/variables_0/other/__init__.py b/tests/variables/testfiles/variables_0/other/__init__.py new file mode 100644 index 0000000..a8386c9 --- /dev/null +++ b/tests/variables/testfiles/variables_0/other/__init__.py @@ -0,0 +1,6 @@ +from calculate.variables.datavars import Namespace, Variable, StringType,\ + IntegerType, BooleanType + +Variable('strange_variable', source='weird_value', type=StringType) + +Variable('plain_variable', source=True, type=BooleanType)