variable/function collision detection
This commit is contained in:
parent
336c8607d9
commit
d33d633dd7
3 changed files with 33 additions and 11 deletions
|
|
@ -76,7 +76,6 @@ class Overrides(DictFormatterValidator, Scriptable):
|
|||
" built-in ytdl-sub function name."
|
||||
)
|
||||
|
||||
|
||||
self.unresolvable.add(VARIABLES.entry_metadata.variable_name)
|
||||
|
||||
def initial_variables(
|
||||
|
|
|
|||
|
|
@ -88,6 +88,15 @@ class VariableValidation:
|
|||
resolved_variables=self.resolved_variables,
|
||||
)
|
||||
|
||||
for added_variable in added_variables:
|
||||
if added_variable in overrides.keys:
|
||||
# pylint: disable=protected-access
|
||||
raise overrides._validation_exception(
|
||||
f"Override variable with name {added_variable} cannot be used since it is a"
|
||||
" built-in ytdl-sub variable added by a plugin."
|
||||
)
|
||||
# pylint: enable=protected-access
|
||||
|
||||
# Set unresolved as variables that are added but do not exist as entry/override variables
|
||||
# Then update resolved variables to reflect that
|
||||
self.unresolved_variables = added_variables | modified_variables
|
||||
|
|
@ -113,15 +122,6 @@ class VariableValidation:
|
|||
).get(plugin_op, set())
|
||||
modified_variables = options.modified_variables().get(plugin_op, set())
|
||||
|
||||
if added_variables:
|
||||
for added_variable in added_variables:
|
||||
if added_variable in self.resolved_variables:
|
||||
# pylint: disable=protected-access
|
||||
raise options._validation_exception(
|
||||
f"Tried added the variable '{added_variable}', but it already "
|
||||
f"exists as a defined variable."
|
||||
)
|
||||
|
||||
resolved_variables = added_variables | modified_variables
|
||||
|
||||
self.script.add(_add_dummy_variables(resolved_variables))
|
||||
|
|
|
|||
|
|
@ -260,13 +260,36 @@ class TestPreset:
|
|||
},
|
||||
)
|
||||
|
||||
def test_preset_error_override_variable_collides_added_variable(
|
||||
self, config_file, output_options, youtube_video
|
||||
):
|
||||
with pytest.raises(
|
||||
ValidationException,
|
||||
match=re.escape(
|
||||
f"Override variable with name subtitles_ext cannot be used since"
|
||||
" it is a built-in ytdl-sub variable added by a plugin."
|
||||
),
|
||||
):
|
||||
_ = Preset(
|
||||
config=config_file,
|
||||
name="test",
|
||||
value={
|
||||
"download": youtube_video,
|
||||
"output_options": {"output_directory": "dir", "file_name": "ack"},
|
||||
"subtitles": {
|
||||
"embed_subtitles": True,
|
||||
},
|
||||
"overrides": {"subtitles_ext": "collide"},
|
||||
},
|
||||
)
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"function_name",
|
||||
[
|
||||
"%extract_field_from_siblings",
|
||||
"%extract_field_from_metadata_array",
|
||||
"%sanitize",
|
||||
"%array"
|
||||
"%array",
|
||||
],
|
||||
)
|
||||
def test_preset_error_override_variable_collides_with_custom_function(
|
||||
|
|
|
|||
Loading…
Reference in a new issue