Printing test execution times and pinning down slow tests with py.test

前端 未结 2 1204
挽巷
挽巷 2020-12-23 20:14

I am running unit tests on a CI server using py.test. Tests use external resources fetched over network. Sometimes test runner takes too long, causing test runner to be abor

2条回答
  •  伪装坚强ぢ
    2020-12-23 20:45

    You can pass the number with --durations

    pytest --durations=0 — Show all times for tests and setup and teardown
    
    pytest --durations=1 — Just show me the slowest
    
    pytest --durations=50 — Slowest 50, with times, … etc
    

    Take refer in: https://medium.com/@brianokken/pytest-durations-0-show-all-times-for-tests-and-setup-and-teardown-848dccac85db

    Or: https://docs.pytest.org/en/latest/usage.html#profiling-test-execution-duration

提交回复
热议问题