User Tools

Site Tools


pytest_notes

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
pytest_notes [2023/12/22 15:26] – [useful links] rajupytest_notes [2023/12/28 01:31] (current) – [who wrote pytest] raju
Line 56: Line 56:
  
 tags | run pytest from main function, pytest run parameterized test tags | run pytest from main function, pytest run parameterized test
 +
 +==== assert actual expected template ====
 +
 +template 1
 +
 +<code>
 +assert Actual == Expected,\
 +    'Expected = {}, Actual = {}'.format(Expected, Actual)
 +</code>
 +
 +template 2
 +
 +<code>
 +from pandas.util.testing import assert_frame_equal
 +assert_frame_equal(df_actual, df_expected)
 +</code>
 +
 +template 3
 +
 +<code>
 +import pytest
 +@pytest.mark.parametrize('input, expected_output', [
 +    ('foo', bar),
 +    ('foo2', bar2),
 +])
 +def test_fancy_func(input, expected_output):
 +    got = fancy_func(input)
 +    assert got == expected_output, 'Expected = {}, got = {}'.format(expected_output, got)
 +</code>
  
 ==== useful links ==== ==== useful links ====
Line 77: Line 106:
 ==== who wrote pytest ==== ==== who wrote pytest ====
   * https://github.com/pytest-dev/pytest/blob/master/AUTHORS   * https://github.com/pytest-dev/pytest/blob/master/AUTHORS
 +
pytest_notes.1703258812.txt.gz · Last modified: 2023/12/22 15:26 by raju