https://docs.pytest.org/en/latest/
python -m pytest
py.test -v
py.test -s # which allows print
Be careful of the arguments sequence, it is reverting the sequence of the @mock.
@mock is python out-of-box feature.
https://docs.python.org/3/library/unittest.mock.html
mock.return_value is to set the return value when the mock method is called.
assert_called
assert_called_once
assert_called_with
assert_called_with_once
assert_any_call
side_effect to raise exception
For unit test coverage, run this command
the coverage report is under the folder htmlcov.
http://www.robinandeer.com/blog/2016/06/22/how-i-test-my-code-part-3/
https://pypi.python.org/pypi/pytest-cov
To find the unused code, run "vulture targetFile or dir"
To run the pytest in eclipse
No comments:
Post a Comment