1. Summary
I don't understand, how I can run Python method after another actions.
2. File
Example of my .py
file:
# First test
for filename in first_folder:
if "Sasha Great" in open(filename).read():
log.debug(filename + " Done")
else:
print("First test failure for " + filename)
3. Expected algoritm
3.1. Tests passed
If all tests passed, print to console:
Test for all files successful passed
3.2. Tests failed
If, for example, one of my tests failure for SashaExample.txt
:
- print
First test failure for SashaExample.txt
; - continue first test for another files;
- if there are more errors as
First test failure for AnotherExample.txt
, print errors to console and continue test;
- if there are more errors as
exit(1)
after running all tests.
I need exit(1)
, that I can see, that I have errors in my tests, if I use Travis CI or AppVeyor.
4. Not helped
4.1. exit(1) after else
If:
for filename in first_folder:
if "Sasha Great" in open(filename).read():
log.debug(filename + " Done")
else:
print("First test failure for " + filename)
exit(1)
Program end after first error. But I need to see all errors.
4.2. Another attempts
- I don't find, how I can solve my problem, in Google;
- I read about Python functions, methods,
atexit
, but I don't understand, how I can solve this problem.