Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

teardown code of package scope fixture should be executed right after last test in that directory #7416

Closed
jcyrss opened this issue Jun 25, 2020 · 2 comments
Labels
topic: fixtures anything involving fixtures directly or indirectly

Comments

@jcyrss
Copy link

jcyrss commented Jun 25, 2020

  • description

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

  • 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

image

@Zac-HD Zac-HD added the topic: fixtures anything involving fixtures directly or indirectly label Jul 8, 2020
@2008820
Copy link

2008820 commented Nov 30, 2020

:param scope: The scope for which this fixture is shared; one of ``"function"`` (default), ``"class"``, ``"module"``, ``"package"`` or ``"session"``.
package 的意思是 session,整个session结束后执行,并不是当前module结束时运行,没有这个BUG,大家可以散了。
Package means session. It is executed after the end of the whole session. It is not run at the end of the current module. Without this bug, you can break up.

@nicoddemus
Copy link
Member

Hi, thanks for the report.

Unfortunately that's how things are implemented now, but there are plans to change how fixtures are finalized in #4871. Closing this for now as a duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: fixtures anything involving fixtures directly or indirectly
Projects
None yet
Development

No branches or pull requests

4 participants