GitHub PullRequestReviewCommentEvent at 2014-01-19 18:40:50
Repository: django
Actor: charettes
Payload: {"comment":{"url":"https://api.github.com/repos/django/django/pulls/comments/8993375","id":8993375,"diff_hunk":"@@ -69,3 +73,26 @@ def test_model_packages(self):\n             Article._meta.get_field('publications').m2m_reverse_name(),\n             'publication_id'\n         )\n+\n+    def test_model_setstate_dj_version(self):\n+        # test whether `django_version` key is present in object state\n+        # if key not found in state, then test will not pass\n+        p = Publication.objects.create(title=\"FooBar\")\n+        state = p.__reduce__()[-1]\n+        self.assertEqual(state['django_version'], get_major_version())\n+\n+    def test_unsupported_unpickle_exception(self):\n+        # ticket 21430\n+        # The __reduce__ function will set the dic['django_version'] to current major version.\n+        # So, we reduce the version number to the last major version to test this exception.\n+        class TestModel(models.Model):\n+            title = models.CharField(max_length=10)\n+            def __reduce__(self):\n+                reduce_list = list(super(TestModel, self).__reduce__())\n+                data = reduce_list[-1]\n+                data['django_version'] = str(float(get_major_version()) - 0.1)\n+                reduce_list[-1] = data\n+                return tuple(reduce_list)","path":"tests/model_package/tests.py","position":36,"original_position":36,"commit_id":"c48ba16dd7c6a375ff44630ee9609ca9ceb58743","original_commit_id":"c48ba16dd7c6a375ff44630ee9609ca9ceb58743","user":{"login":"charettes","id":9293,"avatar_url":"https://gravatar.com/avatar/428a62eedcccc5c82cee1bb972ea3cd5?d=https%3A%2F%2Fidenticons.github.com%2F8ef99bfe02f6d9e5c920cfebe29ee9fb.png&r=x","gravatar_id":"428a62eedcccc5c82cee1bb972ea3cd5","url":"https://api.github.com/users/charettes","html_url":"https://github.com/charettes","followers_url":"https://api.github.com/users/charettes/followers","following_url":"https://api.github.com/users/charettes/following{/other_user}","gists_url":"https://api.github.com/users/charettes/gists{/gist_id}","starred_url":"https://api.github.com/users/charettes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/charettes/subscriptions","organizations_url":"https://api.github.com/users/charettes/orgs","repos_url":"https://api.github.com/users/charettes/repos","events_url":"https://api.github.com/users/charettes/events{/privacy}","received_events_url":"https://api.github.com/users/charettes/received_events","type":"User","site_admin":false},"body":"You don't need to turn `__reduce__` return value to a `list` and then back to a `tuple` nor reassign `data` to `reduce_list[-1]` since you already have a reference.","created_at":"2014-01-19T18:40:50Z","updated_at":"2014-01-19T18:40:50Z","html_url":"https://github.com/django/django/pull/2082#discussion_r8993375","pull_request_url":"https://api.github.com/repos/django/django/pulls/2082","_links":{"self":{"href":"https://api.github.com/repos/django/django/pulls/comments/8993375"},"html":{"href":"https://github.com/django/django/pull/2082#discussion_r8993375"},"pull_request":{"href":"https://api.github.com/repos/django/django/pulls/2082"}}}}