vendredi 1 mai 2020

How can I check my print lines in the pytest?

My function get only one argument and print it with other print lines. It prints some data to stdout. My test should just capture the stdout and verify the data is being printed.

def func_print(name):
    print('')
    print('                     %s' % name)
    print('')
    print('        Copyright - %s Company, Inc.' % time.strftime('%Y'))
    print('        Second sentence.')
    print('')
def test_func_print(name, expected_result):
    assert func_print(name) == expected_result

What should I write in pytest.mark.parametrized section?

Aucun commentaire:

Enregistrer un commentaire