def test_product_string(): assert math_func.product('hello', 3) == 'hellohellohello' result = math_func.product('hello') assert result == 'hellohello' assert type(result) is str assert 'hello' in result
def test_product_string_1(): assert math_func.product('hello ', 3) == 'hello hello hello ' result = math_func.product('hello ') assert result == 'hello hello ' assert type(result) is str assert 'hello' in result # # # Different ways of running scripts # $ pytest # $ pytest -v # $ pytest sample_testing.py -v # with different file name # $ pytest test_math_func.py::test_add # to run specific function # If you just want to run functions with add # $ pytest -v -k "add" # function havig add in name # $ pytest -v -k "add or string" # function having add or string in name # $ pytest -v -k "add and string" # function having add and string in name # Running tests with marker ('-m') option # $ pytest -v -m number # $ pytest -v -m strings # Running tests with ('-x') option # It'll exit with first error # if you want to supress the stack tract means just show if function passed or not # $ pytest -v --tb=no # maximum fail -> $ pytest -v --maxfail=2 # skipping a particular function for test # if you want to show the reason for skips in verbose mode on the terminal # you can pass -rsx to report skipped tests # $ pytest -v -rsx # skipif - to skip in certain condition # Note by default you can't print anything in test file # to do so: $ pytest -v -s # -q will run it in quite mode no unnecessary information shown # $ pytest -q
def test_product(): assert math_func.product(2, 4) == 8 assert math_func.product(5) == 10
def test_product(arg1, arg2, result): assert math_func.product(arg1, arg2) == result
''' entry point ''' import math_func print(math_func.add(2, 5)) print(math_func.product(2, 5)) pass
def test_product(): assert math_func.product(5, 2) == 10 assert math_func.product(2) == 3
def test_product_string(): result = math_func.product('Hello ') assert result == 'Hello Mihail' assert type(result) == str assert 'Hello' in result
def test_product_string(): assert math_func.product('Hello ', 3) == 'Hello Hello Hello ' result = math_func.product('Hello ') assert result == 'Hello Hello ' assert 'Hello' in result
def test_product_strings(): assert math_func.product("Hello ", 3) == 'Hello Hello Hello ' result = math_func.product("Hello ") assert result== 'Hello Hello ' assert type(result) is str assert "Hello" in result
def test_product(): assert math_func.product(7, 3) == 21 assert math_func.product(7) == 14 assert math_func.product(5) == 9
def test_product_strings(): assert math_func.product('Hello ', 3) == 'Hello Hello Hello ' result = math_func.product("hello ") assert result == 'hello hello ' assert type(result) == str assert 'hello' in result
def test_sub(): assert math_func.product(5,5)==25 assert math_func.product(5)==10 assert math_func.product(7)==14
def test_product_strings(): assert math_func.product('hello', 3) == "hellohellohello" result = math_func.product("hello") assert result == "hellohello"
def test_product_strings(): assert math_func.product('Yadda ', 3) == 'Yadda Yadda Yadda ' result = math_func.product('Yadda ') assert result == 'Yadda Yadda ' assert type(result) is str assert 'Ya' in result
def test_product(): assert math_func.product(5, 5) == 25 assert math_func.product(5) == 10 assert math_func.product(-5) == -10 assert math_func.product(2) != 7
def test_product(): """Test second function""" assert math_func.product(5,5)==25 assert math_func.product(5)==10 assert math_func.product(7) == 14
def test_product(): print('++ if you see this -s is passed ++') assert math_func.product(7, 10) == 70 assert math_func.product(7) == 14
def test_product(): assert math_func.product(5, 5) == 25 assert math_func.product(5) == 10
def test_product(): assert math_func.product(4, 9) == 36 assert math_func.product(6) == 12 assert math_func.product(8, 3) == 24