Skip to content

Setting a fixture scope of "package" will not teardown the fixture #3796

@hayleyday

Description

@hayleyday

I am using Windows 10, Python 3.6, and pytest 3.7.1 or 3.7.0 (tested with both).

Here are the libraries I have installed:
atomicwrites 1.1.5
attrs 18.1.0
colorama 0.3.9
more-itertools 4.3.0
pip 9.0.3
pluggy 0.7.1
psutil 5.4.6
py 1.5.4
pyserial 3.4
pytest 3.7.1
setuptools 40.0.0
six 1.11.0
websocket-server 0.4

It appears as though when a fixture is setup with a scope of package, the teardown code does not execute.

Simple example:

@pytest.fixture(scope="package")
def example():
   setup_code()
   yield something
   teardown_code()

For this example, "teardown_code()" is never executed for me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: questiongeneral question, might be closed after 2 weeks of inactivity

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions