Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion secator/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ def set(self, key, value, set_partial=True, strategy=None):
console.print(f'[bold orange1]Value "{item}" not found in {key}[/].')
return
value = current
else:
elif value is not None:
# Try to convert value to expected type
try:
if isinstance(existing_value, list):
Expand Down
13 changes: 13 additions & 0 deletions tests/unit/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,19 @@ def test_set_dict_subkey_tasks_overrides(self):
yaml_data = Config.read_yaml(self.config_test)
self.assertEqual(yaml_data['tasks']['overrides']['nuclei']['input_chunk_size'], 100)

def test_unset_numeric_key(self):
"""Unsetting an int field must drop it from the partial config, not raise TypeError."""
from secator.config import Config
config = Config.parse(path=self.config_test)
default = config.runners.progress_update_frequency
config.set('runners.progress_update_frequency', '30')
config.save()
self.assertEqual(Config.read_yaml(self.config_test)['runners']['progress_update_frequency'], 30)
config.unset('runners.progress_update_frequency')
config.save()
self.assertNotIn('progress_update_frequency', Config.read_yaml(self.config_test).get('runners', {}))
self.assertEqual(Config.parse(path=self.config_test).runners.progress_update_frequency, default)

def _parse_with_env(self, **env):
"""Parse a fresh config with the given SECATOR_* env vars set, then clean them up."""
from secator.config import Config
Expand Down
Loading