easycheck
easycheck copied to clipboard
A module offering Python functions for simple and readable assertion-like checks to be used inside code, but also in testing.
In Python, you can do this: ```python x = [10, ] if x: print("x is not empty") ``` You cannot do this with `easycheck`, as `check_if()` accepts only a Boolean...
Check if the exception class provided has `.message` attribute: if it does and the user did not provide a message, use it; otherwise, don't.
Imagine you have a custom exception that takes some arguments. You cannot pass these arguments using `easycheck`. This tasks aims to enable that, through passing `*args` and `**kwargs` from `easycheck`...
Catching a check is easy with `catch_check()`: ``` >>> check = catch_check(2 == 1, ValueError) >>> check ValuError >>> check = catch_check(2 == 2, ValueError) >>> check ``` What the...
Now, `easycheck` can also raise a single exception. So, it's impossible to ```python raise Exception1 from Exception2 ``` It seems to make sense to enable this functionality. This can be...
Add performance tests (using `perftester`) to analyze and test how the `easycheck` functions perform against their built-in counterparts.
`check_if_not` can have a nice use in the following scenario. Imagine you have two arguments, say `x` and `y`, whose combination of `x == 1 and y == 2` is...
Add function `check_subclass` to check if an object is a subclass. For example: ```python >>> class MyWarning(Warning): pass >>> check_subclass(MyWarning, str) False >>> check_subclass(MyWarning, Warning) True ```
Add function `check_if_sorted()` and its alias `assert_if_sorted()`.
`check_argument()` is actually a function that has potential to be used most often among the `easycheck` functions, so would be good to provide an example of its use in the...