Confirmed users
213
edits
(→Tests) |
|||
| (5 intermediate revisions by 2 users not shown) | |||
| Line 188: | Line 188: | ||
* When doing equivalency assertions, put the expected value first, followed by the actual value, for example: | * When doing equivalency assertions, put the expected value first, followed by the actual value, for example: | ||
<source lang="python"> | <source lang="python"> | ||
assert 'expected' == 'actual' # good | |||
assert 'actual' == 'expected' # bad | |||
assert 'expected | |||
# | |||
assert | |||
</source> | </source> | ||
* When doing negative equivalency, use != and put the unexpected value first, followed by the actual value, for example: | |||
<source lang="python"> | |||
assert 'unexpected' != 'actual' # good | |||
assert 'actual' != 'unexpected' # bad | |||
</source> | |||
* To directly cause a test to fail raise an AssertionError with an appropriate message, for example: | |||
<source lang="python"> | |||
raise AssertionError('message') | |||
</source> | |||
* See [http://pytest.org/latest/assert.html pytest's documentation on asserts] for more help. | |||
= Size of patches = | = Size of patches = | ||