{"action":"created","issue":{"url":"https://api.github.com/repos/pytest-dev/pytest/issues/2547","repository_url":"https://api.github.com/repos/pytest-dev/pytest","labels_url":"https://api.github.com/repos/pytest-dev/pytest/issues/2547/labels{/name}","comments_url":"https://api.github.com/repos/pytest-dev/pytest/issues/2547/comments","events_url":"https://api.github.com/repos/pytest-dev/pytest/issues/2547/events","html_url":"https://github.com/pytest-dev/pytest/issues/2547","id":240383860,"number":2547,"title":"unexpected fixture execution order","user":{"login":"jacexh","id":2589373,"avatar_url":"https://avatars0.githubusercontent.com/u/2589373?v=4","gravatar_id":"","url":"https://api.github.com/users/jacexh","html_url":"https://github.com/jacexh","followers_url":"https://api.github.com/users/jacexh/followers","following_url":"https://api.github.com/users/jacexh/following{/other_user}","gists_url":"https://api.github.com/users/jacexh/gists{/gist_id}","starred_url":"https://api.github.com/users/jacexh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacexh/subscriptions","organizations_url":"https://api.github.com/users/jacexh/orgs","repos_url":"https://api.github.com/users/jacexh/repos","events_url":"https://api.github.com/users/jacexh/events{/privacy}","received_events_url":"https://api.github.com/users/jacexh/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-07-04T10:46:02Z","updated_at":"2017-07-31T12:43:23Z","closed_at":null,"body":"Hi guys,\r\n\r\nI could not understand the execution order between `fixtures` and `setup_*` methods:\r\n\r\n**Here is code example:**\r\n\r\n```python\r\n# -*- coding: utf-8 -*-\r\n\r\nimport pytest\r\nimport logging\r\n\r\nlogger = logging.getLogger(__name__)\r\nlogging.basicConfig(level=logging.INFO)\r\n\r\n\r\n@pytest.yield_fixture(scope=\"class\", autouse=True)\r\ndef fixture_class():\r\n    logger.info(\"fixture_class\")\r\n    yield\r\n    logger.info(\"finish fixture_class\")\r\n\r\n\r\n@pytest.yield_fixture(scope=\"module\", autouse=True)\r\ndef fixture_module():\r\n    logger.info(\"fixture_module\")\r\n    yield\r\n    logger.info(\"finish fixture_module\")\r\n\r\n\r\n@pytest.yield_fixture(scope=\"session\", autouse=True)\r\ndef fixture_session():\r\n    logger.info(\"fixture_session\")\r\n    yield\r\n    logger.info(\"finish fixture_session\")\r\n\r\n\r\ndef setup_module():\r\n    logger.info(\"setup module\")\r\n\r\n\r\ndef teardown_module():\r\n    logging.info(\"teardown module\")\r\n\r\n\r\nclass TestSample:\r\n\r\n    @classmethod\r\n    def setup_class(cls):\r\n        logger.info(\"setup class\")\r\n\r\n    @classmethod\r\n    def teardown_class(cls):\r\n        logger.info(\"teardown class\")\r\n\r\n    def setup(self):\r\n        logger.info(\"setup\")\r\n\r\n    def teardown(self):\r\n        logger.info(\"teardown\")\r\n\r\n    def test_ok(self):\r\n        logger.info(\"test\")\r\n\r\n```\r\n\r\n**Output:**\r\n\r\n```\r\nINFO:cases.test_sample:setup module\r\nINFO:cases.test_sample:setup class\r\nINFO:cases.test_sample:fixture_session\r\nINFO:cases.test_sample:fixture_module\r\nINFO:cases.test_sample:fixture_class\r\nINFO:cases.test_sample:setup\r\nINFO:cases.test_sample:test\r\nINFO:cases.test_sample:teardown\r\nINFO:cases.test_sample:finish fixture_class\r\nINFO:cases.test_sample:teardown class\r\nINFO:cases.test_sample:finish fixture_module\r\nINFO:root:teardown module\r\nINFO:cases.test_sample:finish fixture_session\r\n```\r\n\r\nIn my opinion, the execution order is: `fixture_session` -> `setup_module` -> `fixture_module` -> `setup_class` ...\r\n\r\nI don't undestand why the `fixture_session`/`fixture_module` was invoked after `setup_module`/`setup_class`, is this a bug?"},"comment":{"url":"https://api.github.com/repos/pytest-dev/pytest/issues/comments/319056162","html_url":"https://github.com/pytest-dev/pytest/issues/2547#issuecomment-319056162","issue_url":"https://api.github.com/repos/pytest-dev/pytest/issues/2547","id":319056162,"user":{"login":"RonnyPfannschmidt","id":156838,"avatar_url":"https://avatars1.githubusercontent.com/u/156838?v=4","gravatar_id":"","url":"https://api.github.com/users/RonnyPfannschmidt","html_url":"https://github.com/RonnyPfannschmidt","followers_url":"https://api.github.com/users/RonnyPfannschmidt/followers","following_url":"https://api.github.com/users/RonnyPfannschmidt/following{/other_user}","gists_url":"https://api.github.com/users/RonnyPfannschmidt/gists{/gist_id}","starred_url":"https://api.github.com/users/RonnyPfannschmidt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RonnyPfannschmidt/subscriptions","organizations_url":"https://api.github.com/users/RonnyPfannschmidt/orgs","repos_url":"https://api.github.com/users/RonnyPfannschmidt/repos","events_url":"https://api.github.com/users/RonnyPfannschmidt/events{/privacy}","received_events_url":"https://api.github.com/users/RonnyPfannschmidt/received_events","type":"User","site_admin":false},"created_at":"2017-07-31T12:43:23Z","updated_at":"2017-07-31T12:43:23Z","body":"currently xunit methods are managed by a different system and are not integrated with fixtures"}}
{"actor":{"display_login":"RonnyPfannschmidt"}}