You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Do not use assert statements in place of conditionals or validating preconditions. They must not be critical to the application logic. A litmus test would be that the assert could be removed without breaking the code. assert conditionals are not guaranteed to be evaluated. For pytest based tests, assert is okay and expected to verify expectations.
Per slack discussion, it would be convenient to have a require() function in fgpyo that acts like assert but cannot be disabled.
defrequire(
condition: bool,
message: str|None=None,
error: Exception=RequirementError,
) ->None:
""" Require a condition to be met. Args: condition: The test condition. message: The error message to report. error: The exception class to raise. Raises: `RequirementError`: if `condition` is False. (The `Exception` class raised may be overridden by the `error` argument. """
...
The text was updated successfully, but these errors were encountered:
assert
should be avoided outside unit tests.The Google style guide requires this:
The primary reason to avoid
assert
statements is that they are intended for debugging and can be disabled.Per slack discussion, it would be convenient to have a
require()
function infgpyo
that acts likeassert
but cannot be disabled.The text was updated successfully, but these errors were encountered: