All the pytest documentation there indicates that py.test file_name is the standard way to run pytest test cases. But I am developing in Emacs with a Python script in the left pane and a Python interpreter in the right pane.
My workflow is that I make changes to the Python script, CTRL-C C it (so that the updated changes are sent to REPL) and move to REPL ( CTRL-O ) to test the updated code. It would be nice if I could make changes to my test case on the left, go to the right REPL screen and execute an updated test case.
Is there a way to run pytest test cases from REPL or inside a script, unlike spawning a shell and executing a pytest command?
EDIT . As an aside, I tried to use the main function from pytest and called it in a script, but for some funny reason, the changes were not raised unless I killed the old REPL and started a new one. This does not happen with another Python script, so I'm sure this is related to pytest. Here is the code:
def test_add(): assert myadd(1, 2) == 3 if __name__ == '__main__': pytest.main()
source share