pytest-django icon indicating copy to clipboard operation
pytest-django copied to clipboard

Database setup throwing "--durations" numbers out of whack

Open kingbuzzman opened this issue 2 years ago • 0 comments

Running pytest-xdist with concurrency 20, most of my tests access the database. That means that the first 20 tests set up the database for their individual thread, causing the "setup" for the first 20 tests act as if they take ~80s each.

88.01s setup    module/test_file.py::test_that_happens_to_run_1
87.04s setup    module/test_file.py::test_that_happens_to_run_2
86.41s setup    module/test_file.py::test_that_happens_to_run_3
85.46s setup    module/test_file.py::test_that_happens_to_run_4
85.44s setup    module/test_file.py::test_that_happens_to_run_5
85.31s setup    module/test_file.py::test_that_happens_to_run_6
85.30s setup    module/test_file.py::test_that_happens_to_run_7
84.99s setup    module/test_file.py::test_that_happens_to_run_8
83.58s setup    module/test_file.py::test_that_happens_to_run_9
83.54s setup    module/test_file.py::test_that_happens_to_run_10
83.49s setup    module/test_file.py::test_that_happens_to_run_11
83.16s setup    module/test_file.py::test_that_happens_to_run_12
83.03s setup    module/test_file.py::test_that_happens_to_run_13
82.95s setup    module/test_file.py::test_that_happens_to_run_14
81.64s setup    module/test_file.py::test_that_happens_to_run_15
81.57s setup    module/test_file.py::test_that_happens_to_run_17
80.93s setup    module/test_file.py::test_that_happens_to_run_18
80.73s setup    module/test_file.py::test_that_happens_to_run_19
80.73s setup    module/test_file.py::test_that_happens_to_run_20

Is there a fixture with autouse and scope=session that can start the database, independent of my tests, so the duration is not counted against my test?

kingbuzzman avatar May 18 '22 18:05 kingbuzzman