Skip to content

Commit

Permalink
Merge pull request #12 from etuzon/version_1.1.x
Browse files Browse the repository at this point in the history
version 1.1.0
  • Loading branch information
etuzon authored Jul 4, 2024
2 parents 2d2f097 + 4d04995 commit d6c4f84
Show file tree
Hide file tree
Showing 8 changed files with 577 additions and 482 deletions.
44 changes: 23 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,24 @@

### Supported asserts:

| Assert | Description | Example | Return |
|-------------------------------------------------------------|---------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------|----------------------------------------------------|
| assert_true(condition, message=None) | Verify that condition is True | soft_asserts.assert_true(a == b) | True if assertion passes, False if assertion fails |
| assert_false(condition, message=None) | Verify that condition is False | soft_asserts.assert_false(a == b) | True if assertion passes, False if assertion fails |
| assert_equal(first, second, message=None) | Verify that first is equal to second | soft_asserts.assert_equal(a, b) | True if assertion passes, False if assertion fails |
| assert_not_equal(first, second, message=None) | Verify that first is not equal to second | soft_asserts.assert_not_equal(a, b) | True if assertion passes, False if assertion fails |
| assert_is(first, second, message=None) | Verify that first and second are the same object | soft_asserts.assert_is(a, b) | True if assertion passes, False if assertion fails |
| assert_is_not(first, second, message=None) | Verify that first and second are not the same object | soft_asserts.assert_is_not(a, b) | True if assertion passes, False if assertion fails |
| assert_is_none(obj, message=None) | Verify that obj is None | soft_asserts.assert_is_none(a) | True if assertion passes, False if assertion fails |
| assert_is_not_none(obj, message=None) | Verify that obj is not None | soft_asserts.assert_is_not_none(a) | True if assertion passes, False if assertion fails |
| assert_in(obj, container, message=None) | Verify that obj is in container | soft_asserts.assert_in(a, [a, b, c]) | True if assertion passes, False if assertion fails |
| assert_not_in(obj, container, message=None) | Verify that obj is not in container | soft_asserts.assert_not_in(a, [b, c]) | True if assertion passes, False if assertion fails |
| assert_is_instance(obj, cls, message=None) | Verify that obj is instance of cls | soft_asserts.assert_is_instance(a, A) | True if assertion passes, False if assertion fails |
| assert_is_not_instance(obj, cls, message=None) | Verify that obj is not instance of cls | soft_asserts.assert_is_not_instance(a, B) | True if assertion passes, False if assertion fails |
| assert_almost_equal(first, second, delta, message=None) | Verify that first is almost equal to second<br/>and the different is equal or less to delta | soft_asserts.assert_almost_equal(1.001, 1.002, 0.1) | True if assertion passes, False if assertion fails |
| assert_not_almost_equal(first, second, delta, message=None) | Verify that first is not almost equal to second<br/>and the different is more than delta | soft_asserts.assert_not_almost_equal(1.001, 1.002, 0.00001) | True if assertion passes, False if assertion fails |
| assert_raises(exception, method: Callable, *args, **kwargs) | Verify that method execution raise exception | soft_asserts.assert_raises(TypeError, sum, 'a', 2) | True if assertion passes, False if assertion fails |
| assert_raises_with(exception, message=None) | Verify that execution in 'with' block raise exception | with soft_asserts.assert_raised_with(ValueError):<br/>&nbsp;&nbsp;&nbsp;&nbsp;raise ValueError(ERROR_MESSAGE_1) | |
| Assert | Description | Example | Return |
|-------------------------------------------------------------|-----------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------|-----------------------------------------------------|
| assert_true(condition, message=None) | Verify that condition is True. | soft_asserts.assert_true(a == b) | True if assertion passes, False if assertion fails. |
| assert_false(condition, message=None) | Verify that condition is False. | soft_asserts.assert_false(a == b) | True if assertion passes, False if assertion fails. |
| assert_equal(first, second, message=None) | Verify that first is equal to second. | soft_asserts.assert_equal(a, b) | True if assertion passes, False if assertion fails. |
| assert_not_equal(first, second, message=None) | Verify that first is not equal to second. | soft_asserts.assert_not_equal(a, b) | True if assertion passes, False if assertion fails. |
| assert_is(first, second, message=None) | Verify that first and second are the same object. | soft_asserts.assert_is(a, b) | True if assertion passes, False if assertion fails. |
| assert_is_not(first, second, message=None) | Verify that first and second are not the same object. | soft_asserts.assert_is_not(a, b) | True if assertion passes, False if assertion fails. |
| assert_is_none(obj, message=None) | Verify that obj is None. | soft_asserts.assert_is_none(a) | True if assertion passes, False if assertion fails. |
| assert_is_not_none(obj, message=None) | Verify that obj is not None. | soft_asserts.assert_is_not_none(a) | True if assertion passes, False if assertion fails. |
| assert_in(obj, container, message=None) | Verify that obj is in container. | soft_asserts.assert_in(a, [a, b, c]) | True if assertion passes, False if assertion fails. |
| assert_not_in(obj, container, message=None) | Verify that obj is not in container. | soft_asserts.assert_not_in(a, [b, c]) | True if assertion passes, False if assertion fails. |
| assert_is_instance(obj, cls, message=None) | Verify that obj is instance of cls. | soft_asserts.assert_is_instance(a, A) | True if assertion passes, False if assertion fails. |
| assert_is_not_instance(obj, cls, message=None) | Verify that obj is not instance of cls. | soft_asserts.assert_is_not_instance(a, B) | True if assertion passes, False if assertion fails. |
| assert_almost_equal(first, second, delta, message=None) | Verify that first is almost equal to second,<br/>and the different is equal or less to delta. | soft_asserts.assert_almost_equal(1.001, 1.002, 0.1) | True if assertion passes, False if assertion fails. |
| assert_not_almost_equal(first, second, delta, message=None) | Verify that first is not almost equal to second,<br/>and the different is more than delta. | soft_asserts.assert_not_almost_equal(1.001, 1.002, 0.00001) | True if assertion passes, False if assertion fails. |
| assert_raises(exception, method: Callable, *args, **kwargs) | Verify that method execution raise exception. | soft_asserts.assert_raises(TypeError, sum, 'a', 2) | True if assertion passes, False if assertion fails. |
| assert_raises_with(exception, message=None) | Verify that execution in 'with' block raise exception. | with soft_asserts.assert_raised_with(ValueError):<br/>&nbsp;&nbsp;&nbsp;&nbsp;raise ValueError(ERROR_MESSAGE_1) | |

In the end of each test, the soft asserts will be verified and the test will be marked as failed if any of the asserts failed.<br/>
Expand Down Expand Up @@ -109,13 +109,15 @@ def test_skip_if_step_2_fail():
#### Print error on each failed assert

Each assertion failure can be printed.<br/>
This can be done by adding logger or by adding a print method.<br/><br/>
This can be done by adding logger or by adding a print method.<br/>

In case a logger will be added to soft asserts, then logger.error(message) will be used.<br/>

In case a print method will be added to soft asserts, then print_method(message) will be used.<br/></br>
In case a print method will be added to soft asserts, then print_method(message) will be used.<br/>

_logger and print method cannot be added together._<br/><br/>
#### Error format

`message [file_path: line_number] code_line`

#### logger example:

Expand Down
6 changes: 6 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# nrt-pytest-soft-asserts

## Version 1.1.0

### New features:

Error message is in `message [file_path: line_number] code_line` format.

## Version 1.0.9

Support in latest version of pytest.
Expand Down
Loading

0 comments on commit d6c4f84

Please sign in to comment.