QA/Execution/Web Testing/Docs/Automation/StyleGuide: Difference between revisions

Undo revision 1105014 by Jlorenzo (talk) - I edited the wrong page
(Undo revision 1105014 by Jlorenzo (talk) - I edited the wrong page)
 
(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">
# Good
assert 'expected' == 'actual'  # good
a = some_function()
assert 'actual' == 'expected' # bad
assert 'expected result' == a
 
# Bad
a = some_function()
assert a == 'expected result'
</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 =
Confirmed users
213

edits