-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Closed
Labels
plugin: unittestrelated to the unittest integration builtin pluginrelated to the unittest integration builtin plugintopic: fixturesanything involving fixtures directly or indirectlyanything involving fixtures directly or indirectlytype: bugproblem that needs to be addressedproblem that needs to be addressed
Milestone
Description
Originally reported by: Haak Saxberg (BitBucket: haaksmash, GitHub: haaksmash)
consider the following dummy test file:
#!python
import pytest
@pytest.yield_fixture(scope="session", autouse=True)
def print_session():
print "session fixture"
yield
print "session teardown"
class TestClass(object):
def setup_method(self, method):
print "method setup"
def teardown_method(self, method):
print "method teardown"
def test_printer(self):
print "test method"
pytest --capture=no test_file.py
will generate the following output:
#!bash
==================== test session starts ====================
platform darwin -- Python 2.7.5 -- py-1.4.20 -- pytest-2.5.2
collected 1 items
tests/test_ordering.py method setup
session fixture
test method
.method teardown
session teardown
================= 1 passed in 0.01 seconds =================
it looks like all setup_*
methods are invoked before any fixtures are processed, but the teardown_*
methods are called in the order you'd expect:
- method_fixture post-yield
- method_teardown
- class_fixture post-yield
- class_teardown
- module_fixture post-yield
- module_teardown
etc, etc.
that doesn't seem right, especially since the teardowns are in the correct order. In fact it's pretty bad, because you might (I would think rightly) depend on the session having been set up already in your setup_method
.
alongouldman and iRhonin
Metadata
Metadata
Assignees
Labels
plugin: unittestrelated to the unittest integration builtin pluginrelated to the unittest integration builtin plugintopic: fixturesanything involving fixtures directly or indirectlyanything involving fixtures directly or indirectlytype: bugproblem that needs to be addressedproblem that needs to be addressed