Test file :
from RansomNote import Solution
def test_canConstruct():
sol = Solution()
assert sol.canConstruct('aa', 'aab') == True
assert sol.canConstruct('xx','aaabc') == True
assert sol.canConstruct('aab','ababa') == True
Ouput after running pytest -v :
==================================================================== short test summary info =====================================================================
FAILED Easy/test_ransomNote.py::test_canConstruct - AssertionError: assert False == True
======================================================================= 1 failed in 0.01s
QUESTION : First of all, is it ok to have many assert statements in the same test function or is it not recommended? In output it just says assertion error, how to know which assert statement is actually causing the failure? Is it better to create a new test function for each assert statement?
Tried pytest -v Expected which assert statement caused the failure. Output result : FAILED Easy/test_ransomNote.py::test_canConstruct - AssertionError: assert False == True
Pytest will print a string that follows the assert, so you could do this: