if I have this code
def soft_assert(condition):
if not condition:
print('start')
traceback.print_stack()
print('finish')
soft_assert(False)
soft_assert(False)
the output is different every time I run it:
File "/Users/spleshakov/Documents/api-testing-with-pytest/tenants/test_uc.py", line 38, in <module>
soft_assert(False, 'message 1')
File "/Users/spleshakov/Documents/api-testing-with-pytest/tenants/test_uc.py", line 30, in soft_assert
traceback.print_stack()
File "/Users/spleshakov/Documents/api-testing-with-pytest/tenants/test_uc.py", line 41, in <module>
soft_assert(False, 'message 4')
File "/Users/spleshakov/Documents/api-testing-with-pytest/tenants/test_uc.py", line 30, in soft_assert
traceback.print_stack()
start
finish
start
finish
or
start
finish
start
finish
File "/Users/spleshakov/Documents/api-testing-with-pytest/tenants/test_uc.py", line 38, in <module>
soft_assert(False)
File "/Users/spleshakov/Documents/api-testing-with-pytest/tenants/test_uc.py", line 30, in soft_assert
traceback.print_stack()
File "/Users/spleshakov/Documents/api-testing-with-pytest/tenants/test_uc.py", line 41, in <module>
soft_assert(False)
File "/Users/spleshakov/Documents/api-testing-with-pytest/tenants/test_uc.py", line 30, in soft_assert
traceback.print_stack()
The output can be in any order you can think of
This doesn't make sense to me, I can't find an answer, so I was hoping the community can help me with these questions:
- Why this is happening?
- How do I make wait one
printto finish, before doing another one?
Thanks