Your versions do not allow passing additional arguments to pytest (e.g. allow ./test_file.py -v ). I tried just
import sys if __name__ == '__main__': pytest.main(sys.argv)
and it seems like a trick. sys.argv[0] is the name of the script (that is, __file__ , possibly as a relative path), so it restricts the call to the script and sys.argv[1:] contains additional arguments passed to the command line.
Any best idea appreciated!
Matthieu moy
source share