The testing module raises exceptions using assert statements in helper functions. While using assert statements in tests is okay, checking and raising explicit exceptions in the library is better.
For example, in this method, I suggest raising a custom exception.
Creating custom testing module exceptions is a better solution to handle known error conditions. The pytest tests will receive these exceptions, making the test fail.
The testing module raises exceptions using
assert
statements in helper functions. While using assert statements in tests is okay, checking and raising explicit exceptions in the library is better.For example, in this method, I suggest raising a custom exception.
https://github.com/wazuh/wazuh-qa/blob/e71e39aea2caeb0dceab9645fe4f9343152a8a83/deployability/modules/testing/tests/helpers/agent.py#L92-L106
Creating custom testing module exceptions is a better solution to handle known error conditions. The pytest tests will receive these exceptions, making the test fail.