{"action":"created","issue":{"url":"https://api.github.com/repos/nose-devs/nose2/issues/267","repository_url":"https://api.github.com/repos/nose-devs/nose2","labels_url":"https://api.github.com/repos/nose-devs/nose2/issues/267/labels{/name}","comments_url":"https://api.github.com/repos/nose-devs/nose2/issues/267/comments","events_url":"https://api.github.com/repos/nose-devs/nose2/issues/267/events","html_url":"https://github.com/nose-devs/nose2/pull/267","id":133929203,"number":267,"title":"refactor layers","user":{"login":"little-dude","id":6646324,"avatar_url":"https://avatars.githubusercontent.com/u/6646324?v=3","gravatar_id":"","url":"https://api.github.com/users/little-dude","html_url":"https://github.com/little-dude","followers_url":"https://api.github.com/users/little-dude/followers","following_url":"https://api.github.com/users/little-dude/following{/other_user}","gists_url":"https://api.github.com/users/little-dude/gists{/gist_id}","starred_url":"https://api.github.com/users/little-dude/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/little-dude/subscriptions","organizations_url":"https://api.github.com/users/little-dude/orgs","repos_url":"https://api.github.com/users/little-dude/repos","events_url":"https://api.github.com/users/little-dude/events{/privacy}","received_events_url":"https://api.github.com/users/little-dude/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-02-16T09:32:44Z","updated_at":"2016-02-16T09:38:29Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/nose-devs/nose2/pulls/267","html_url":"https://github.com/nose-devs/nose2/pull/267","diff_url":"https://github.com/nose-devs/nose2/pull/267.diff","patch_url":"https://github.com/nose-devs/nose2/pull/267.patch"},"body":"This is an attempt to fix https://github.com/nose-devs/nose2/issues/215\r\n\r\nThe problem is that when sorting the layers, we treat layer mixins and layer parents the same way. Mixins cannot be treated like regular layers, because they don't always have parents. Instead, mixins should be inserted between the layer the parent layer and the layers they belong to, whatever their parents are.\r\n\r\nTo take the example given in the issue, here is how layers are currently resolved:\r\n```\r\nno layer ->\r\n  <class 'test_such_timing.Layer1'> ->\r\n    <class 'test_such_timing.A system with a fast initial setup layer:layer'> ->\r\n     test 0000: should not have obj initialized (test_such_timing.A system with a fast initial setup layer)\r\n      <class 'test_such_timing.having a second slow setup layer:layer'> ->\r\n       test 0000: should have obj initialized (test_such_timing.having a second slow setup layer)\r\n      <- <class 'test_such_timing.having a second slow setup layer:layer'>\r\n    <- <class 'test_such_timing.A system with a fast initial setup layer:layer'>\r\n  <- <class 'test_such_timing.Layer1'>\r\n  <class 'test_such_timing.Layer2'> ->\r\n  <- <class 'test_such_timing.Layer2'>\r\n<- no layer\r\n```\r\n\r\n`Layer2` is a mixin of the `having a second slow setup` layer, so it should enclose this layer. It does not because since it has no parent layer, the current algorithm to sort layers considers it is a base layer.\r\n\r\nWith this PR layers are sorted like this:\r\n\r\n```\r\nno layer ->\r\n  <class 'test_such_timing.Layer1'> ->\r\n    <class 'test_such_timing.A system with a fast initial setup layer:layer'> ->\r\n     test 0000: should not have obj initialized (test_such_timing.A system with a fast initial setup layer)\r\n      <class 'test_such_timing.Layer2'> ->\r\n        <class 'test_such_timing.having a second slow setup layer:layer'> ->\r\n         test 0000: should have obj initialized (test_such_timing.having a second slow setup layer)\r\n        <- <class 'test_such_timing.having a second slow setup layer:layer'>\r\n      <- <class 'test_such_timing.Layer2'>\r\n    <- <class 'test_such_timing.A system with a fast initial setup layer:layer'>\r\n  <- <class 'test_such_timing.Layer1'>\r\n<- no layer\r\n```\r\n\r\nOne unit-test still fails, but this is because it basically verifies the problematic behavior.\r\n\r\nThere is still work to do (adding tests, splitting this into several smaller commits, etc), but if anyone has feedback about this, I'd like to hear. @jpellerin I'd be interested in your opinion, since you seem to be the main architect of this layers feature (btw, thanks for all the super detailled unit and functional tests)."},"comment":{"url":"https://api.github.com/repos/nose-devs/nose2/issues/comments/184598214","html_url":"https://github.com/nose-devs/nose2/pull/267#issuecomment-184598214","issue_url":"https://api.github.com/repos/nose-devs/nose2/issues/267","id":184598214,"user":{"login":"little-dude","id":6646324,"avatar_url":"https://avatars.githubusercontent.com/u/6646324?v=3","gravatar_id":"","url":"https://api.github.com/users/little-dude","html_url":"https://github.com/little-dude","followers_url":"https://api.github.com/users/little-dude/followers","following_url":"https://api.github.com/users/little-dude/following{/other_user}","gists_url":"https://api.github.com/users/little-dude/gists{/gist_id}","starred_url":"https://api.github.com/users/little-dude/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/little-dude/subscriptions","organizations_url":"https://api.github.com/users/little-dude/orgs","repos_url":"https://api.github.com/users/little-dude/repos","events_url":"https://api.github.com/users/little-dude/events{/privacy}","received_events_url":"https://api.github.com/users/little-dude/received_events","type":"User","site_admin":false},"created_at":"2016-02-16T09:38:29Z","updated_at":"2016-02-16T09:38:29Z","body":"For the record, here is the failing unit test: https://github.com/nose-devs/nose2/pull/267/files#diff-63735bdc208b91690ebea2cac1ae65ecR223"}}