Does pytest only run the modified file?

I am new to Python trying to learn a toolbox.

I figured out how to get py.test -fto see my tests as I code. One thing that I could not understand is if there is a way to make a smarter observer that works like a Ruby Guard library.

Using guard + minitest, I get that if I save the type file my_class.rb, then it is executed my_class_test.rb, and if I delete enterin cli, it will run all the tests.

With pytest so far, I have not been able to figure out a way to run only the test file corresponding to the last affected file, which avoids waiting for the entire test suite to complete until I get the current file going through.

How could you make pythonistas?

Thanks!

+4
source share
2 answers

One possibility is to use pytest-testmon with pytest-watch .

It uses coverage.py to track which test affects which lines of code, and as soon as you change the line of code, -runs all tests that somehow execute this line.

+8
source

There is also pytest-xdist , which has a function:

- looponfail: . py.test , , . , , .

0

Source: https://habr.com/ru/post/1626619/


All Articles