{"action":"created","issue":{"url":"https://api.github.com/repos/testing-cabal/testtools/issues/158","labels_url":"https://api.github.com/repos/testing-cabal/testtools/issues/158/labels{/name}","comments_url":"https://api.github.com/repos/testing-cabal/testtools/issues/158/comments","events_url":"https://api.github.com/repos/testing-cabal/testtools/issues/158/events","html_url":"https://github.com/testing-cabal/testtools/pull/158","id":114788449,"number":158,"title":"Extract TestRecord object from StreamToDict","user":{"login":"jml","id":125674,"avatar_url":"https://avatars.githubusercontent.com/u/125674?v=3","gravatar_id":"","url":"https://api.github.com/users/jml","html_url":"https://github.com/jml","followers_url":"https://api.github.com/users/jml/followers","following_url":"https://api.github.com/users/jml/following{/other_user}","gists_url":"https://api.github.com/users/jml/gists{/gist_id}","starred_url":"https://api.github.com/users/jml/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jml/subscriptions","organizations_url":"https://api.github.com/users/jml/orgs","repos_url":"https://api.github.com/users/jml/repos","events_url":"https://api.github.com/users/jml/events{/privacy}","received_events_url":"https://api.github.com/users/jml/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-11-03T10:51:54Z","updated_at":"2015-11-09T13:29:18Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/testing-cabal/testtools/pulls/158","html_url":"https://github.com/testing-cabal/testtools/pull/158","diff_url":"https://github.com/testing-cabal/testtools/pull/158.diff","patch_url":"https://github.com/testing-cabal/testtools/pull/158.patch"},"body":"Many places in `testtools.testresult.real` refer to \"a dict as generated by `StreamToDict`\" or similar. This patch dignifies it with a real name in Python, `TestRecord`\r\n\r\nThe new `TestRecord` object encapsulates most of the information in the dict and has been extracted from `StreamToDict`. \r\n\r\nI've made it inherit from `pyrsistent.PClass` to make it immutable. I think this is a desirable property, but not essential to the patch. We could make it mutable with attrs, or by rolling our own object like in the olden days. \r\n\r\n## Notes\r\n* adds [pyrsistent](http://pyrsistent.readthedocs.org/) as a dependency\r\n* I've left a couple of `XXX` comments in where feedback is particularly welcome\r\n* neither `TestRecord` nor `StreamToTestRecord` is exposed, we can do that here or in a separate patch\r\n* I was unclear on the backwards compatibility promises of `testtools.testresult.real` so I've tried very hard to avoid changing behaviour\r\n* while working on this, I really wanted to move all the \"stream\" stuff to a separate module, `_stream`. I held off because:\r\n    * I wanted to keep the patch small\r\n    * I don't know about backwards compatibility\r\n* `TestRecord` stores timestamps as a tuple. It occurred to me late in the piece that it would be clearer to use `start_time` and `end_time` or similar.\r\n* gives explicit names to \"status\" constants, but there's still duplication here, and ideally I'd like to have something a bit more structured (maybe w/ https://github.com/twisted/constantly/)\r\n* extracted base class `StreamToTestRecord` from `StreamToDict`, and then made `StreamToDict` use (rather than inherit from) `StreamToTestRecord` to do its thing\r\n* no test changes because I've tried to do strict refactoring\r\n\r\n## Context\r\n\r\nI'm looking at re-using some code from `testtools.testresult`. This patch is in the spirit of \"building understanding into existing code\".\r\n\r\n<!-- Reviewable:start -->\r\n[<img src=\"https://reviewable.io/review_button.png\" height=40 alt=\"Review on Reviewable\"/>](https://reviewable.io/reviews/testing-cabal/testtools/158)\r\n<!-- Reviewable:end -->\r\n"},"comment":{"url":"https://api.github.com/repos/testing-cabal/testtools/issues/comments/155061603","html_url":"https://github.com/testing-cabal/testtools/pull/158#issuecomment-155061603","issue_url":"https://api.github.com/repos/testing-cabal/testtools/issues/158","id":155061603,"user":{"login":"jml","id":125674,"avatar_url":"https://avatars.githubusercontent.com/u/125674?v=3","gravatar_id":"","url":"https://api.github.com/users/jml","html_url":"https://github.com/jml","followers_url":"https://api.github.com/users/jml/followers","following_url":"https://api.github.com/users/jml/following{/other_user}","gists_url":"https://api.github.com/users/jml/gists{/gist_id}","starred_url":"https://api.github.com/users/jml/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jml/subscriptions","organizations_url":"https://api.github.com/users/jml/orgs","repos_url":"https://api.github.com/users/jml/repos","events_url":"https://api.github.com/users/jml/events{/privacy}","received_events_url":"https://api.github.com/users/jml/received_events","type":"User","site_admin":false},"created_at":"2015-11-09T13:29:18Z","updated_at":"2015-11-09T13:29:18Z","body":"This is now ready for review."}}