简体   繁体   中英

How to make a test function using pytest

I don't know how to make test function. I have this function

import pytest

def added(a, b, c):
    d = b + c
    e = a + c
    f = a + b
    return (d, e, f)

added(4,6,7)

How I can make a test_function for this function.

Thanks for any help in advance

Try this:

def test_added():
    assert added(4, 6, 7) == (13, 11, 10)

Then execute your test function. If all test are correct, you should get something like:

1 passed in x.xx seconds

Check the docs for more help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM