if we define a fixture with package scope, and the fixture function registers a finalizer, we will see finalizer teardown code executing not directly after the last test in that directory.
I think ensure it executing right after the last test in that directory is important, because if not so, the data created during setup in this directory may ruin tests in other directory
download the following, unzip and run
cases.zip
you will see the output like the following, in which teardown of login directory should be right after last test in that directory

if we define a fixture with
packagescope, and the fixture function registers a finalizer, we will see finalizer teardown code executing not directly after the last test in that directory.I think ensure it executing right after the last test in that directory is important, because if not so, the data created during setup in this directory may ruin tests in other directory
OS Version
Windows 10
pytest version
pytest-5.4.3
example
download the following, unzip and run
cases.zip
you will see the output like the following, in which teardown of login directory should be right after last test in that directory