Skip to content

Commit

Permalink
refac: Refac path error raise. #2075
Browse files Browse the repository at this point in the history
Now `if-in` with `dict.keys()` is used instead of `try-except`.
  • Loading branch information
Luis Gonzalez committed Oct 20, 2021
1 parent df873bb commit 75fdcc3
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions deps/wazuh_testing/wazuh_testing/qa_docs/lib/code_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,15 +204,14 @@ def parse_test(self, path, id, group_id):
module_doc['name'] = os.path.basename(path)
module_doc['id'] = id
module_doc['group_id'] = group_id
# If the path is specified within the documentation block, it raises an error
try:
if module_doc['path']:
CodeParser.LOGGER.error('Path field is an autogenerated field, you must not specify it.')
raise QAValueError('Path field is an autogenerated field, you must not specify it.',
CodeParser.LOGGER.error)
# If not, it is autogenerated
except:
module_doc['path'] = re.sub(r'.*wazuh-qa\/', '', path)

# If the path is specified within the documentation block, it logs an error
if 'path' in module_doc.keys():
CodeParser.LOGGER.error('Path field is an autogenerated field, you must not specify it.')
raise QAValueError('Path field is an autogenerated field, you must not specify it.',
CodeParser.LOGGER.error)

module_doc['path'] = re.sub(r'.*wazuh-qa\/', '', path)

functions_doc = []
for function in functions:
Expand Down

0 comments on commit 75fdcc3

Please sign in to comment.