Calling and collecting results from py.test from code

I am working on a system that should be able to check python files with py.test and use the output (which tests passed and failed) in the program. In any case, to call py.test from python, tell him to run the test code in [name] .py on the code in [otherName] .py and whether he will return the test results?

+4
source share
1 answer

I think you are looking for a pytest call from Python code in Use and Invocations .

Also, the test restriction for a specific file can be performed by Test assignment / test selection .

In other words, this should do the trick:

pytest.main(['my_test_file.py']) 

PS: Py.test Documantation is pretty good, you can find answers to most of the answers;).

+2
source

All Articles