{"action":"created","comment":{"url":"https://api.github.com/repos/twisted/twisted/pulls/comments/126274092","pull_request_review_id":48748384,"id":126274092,"diff_hunk":"@@ -1911,5 +1956,83 @@ def test_hooksNotCalled(self):\n \n \n \n+class ExitWithSignalTests(unittest.TestCase):\n+\n+    \"\"\"\n+    Tests for L{twisted.application.app._exitWithSignal}.\n+    \"\"\"\n+\n+    def setUp(self):\n+        \"\"\"\n+        Set up the server options and a fake for use by test cases.\n+        \"\"\"\n+        self.config = twistd.ServerOptions()\n+        self.config.loadedPlugins = {'test_command': MockServiceMaker()}\n+        self.config.subOptions = object()\n+        self.config.subCommand = 'test_command'\n+        self.exitWithSignalCalled = False\n+\n+        def fakeExitWithSignal(sig):\n+            self.exitWithSignalCalled = True\n+\n+        self.fakeExitWithSignal = fakeExitWithSignal\n+\n+\n+    def test_exitWithSignal(self):\n+        \"\"\"\n+        exitWithSignal replaces the existing signal handler with the default\n+        handler and sends the replaced signal to the current process.\n+        \"\"\"\n+\n+        fakeSignalArgs = [None, None]\n+\n+        def fake_signal(sig, handler):\n+            fakeSignalArgs[0] = sig\n+            fakeSignalArgs[1] = handler\n+\n+\n+        fakeKillArgs = [None, None]\n+\n+        def fake_kill(pid, sig):\n+            fakeKillArgs[0] = pid\n+            fakeKillArgs[1] = sig\n+\n+        self.patch(signal, 'signal', fake_signal)\n+        self.patch(os, 'kill', fake_kill)\n+        app._exitWithSignal(signal.SIGINT)\n+\n+        self.assertEquals(fakeSignalArgs[0], signal.SIGINT)\n+        self.assertEquals(fakeSignalArgs[1], signal.SIG_DFL)\n+        self.assertEquals(fakeKillArgs[0], os.getpid())\n+        self.assertEquals(fakeKillArgs[1], signal.SIGINT)\n+\n+\n+    def test_normalExit(self):\n+        \"\"\"\n+        _exitWithSignal is not called if the runner does not exit with a\n+        signal.\n+        \"\"\"\n+        self.patch(twistd.app, '_exitWithSignal', self.fakeExitWithSignal)\n+        self.patch(twistd, '_SomeApplicationRunner', CrippledApplicationRunner)\n+        twistd.runApp(self.config)\n+        self.assertFalse(self.exitWithSignalCalled)\n+\n+\n+    def test_runnerExitsWithSignal(self):\n+        \"\"\"\n+        _exitWithSignal is called when the runner exits with a signal.\n+        \"\"\"\n+        CrippledApplicationRunner._exitSignal = 2\n+        self.patch(twistd.app, '_exitWithSignal', self.fakeExitWithSignal)\n+        self.patch(twistd, '_SomeApplicationRunner', CrippledApplicationRunner)\n+        twistd.runApp(self.config)\n+        self.assertTrue(self.exitWithSignalCalled)\n+\n+\n+    def tearDown(self):\n+        CrippledApplicationRunner._exitSignal = 0","path":"src/twisted/test/test_twistd.py","position":139,"original_position":139,"commit_id":"add82a87be83592b26ea21bcdae47b6b55144f91","original_commit_id":"add82a87be83592b26ea21bcdae47b6b55144f91","user":{"login":"glyph","id":716529,"avatar_url":"https://avatars0.githubusercontent.com/u/716529?v=3","gravatar_id":"","url":"https://api.github.com/users/glyph","html_url":"https://github.com/glyph","followers_url":"https://api.github.com/users/glyph/followers","following_url":"https://api.github.com/users/glyph/following{/other_user}","gists_url":"https://api.github.com/users/glyph/gists{/gist_id}","starred_url":"https://api.github.com/users/glyph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/glyph/subscriptions","organizations_url":"https://api.github.com/users/glyph/orgs","repos_url":"https://api.github.com/users/glyph/repos","events_url":"https://api.github.com/users/glyph/events{/privacy}","received_events_url":"https://api.github.com/users/glyph/received_events","type":"User","site_admin":false},"body":"Is this expected to be set by the system under test?  If not, it would be more appropriate to use `.patch` for this.","created_at":"2017-07-08T04:10:41Z","updated_at":"2017-07-08T04:13:32Z","html_url":"https://github.com/twisted/twisted/pull/826#discussion_r126274092","pull_request_url":"https://api.github.com/repos/twisted/twisted/pulls/826","_links":{"self":{"href":"https://api.github.com/repos/twisted/twisted/pulls/comments/126274092"},"html":{"href":"https://github.com/twisted/twisted/pull/826#discussion_r126274092"},"pull_request":{"href":"https://api.github.com/repos/twisted/twisted/pulls/826"}}},"pull_request":{"url":"https://api.github.com/repos/twisted/twisted/pulls/826","id":127133040,"html_url":"https://github.com/twisted/twisted/pull/826","diff_url":"https://github.com/twisted/twisted/pull/826.diff","patch_url":"https://github.com/twisted/twisted/pull/826.patch","issue_url":"https://api.github.com/repos/twisted/twisted/issues/826","number":826,"state":"open","locked":false,"title":"761-signal-exit","user":{"login":"jlitzingerdev","id":1496650,"avatar_url":"https://avatars3.githubusercontent.com/u/1496650?v=3","gravatar_id":"","url":"https://api.github.com/users/jlitzingerdev","html_url":"https://github.com/jlitzingerdev","followers_url":"https://api.github.com/users/jlitzingerdev/followers","following_url":"https://api.github.com/users/jlitzingerdev/following{/other_user}","gists_url":"https://api.github.com/users/jlitzingerdev/gists{/gist_id}","starred_url":"https://api.github.com/users/jlitzingerdev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jlitzingerdev/subscriptions","organizations_url":"https://api.github.com/users/jlitzingerdev/orgs","repos_url":"https://api.github.com/users/jlitzingerdev/repos","events_url":"https://api.github.com/users/jlitzingerdev/events{/privacy}","received_events_url":"https://api.github.com/users/jlitzingerdev/received_events","type":"User","site_admin":false},"body":"Pull request for https://twistedmatrix.com/trac/ticket/761","created_at":"2017-06-23T04:36:05Z","updated_at":"2017-07-08T04:13:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"08f36723bc2052c3f658c5c0ba9f8f15a8180d2d","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/twisted/twisted/pulls/826/commits","review_comments_url":"https://api.github.com/repos/twisted/twisted/pulls/826/comments","review_comment_url":"https://api.github.com/repos/twisted/twisted/pulls/comments{/number}","comments_url":"https://api.github.com/repos/twisted/twisted/issues/826/comments","statuses_url":"https://api.github.com/repos/twisted/twisted/statuses/add82a87be83592b26ea21bcdae47b6b55144f91","head":{"label":"jlitzingerdev:761-signal-exit","ref":"761-signal-exit","sha":"add82a87be83592b26ea21bcdae47b6b55144f91","user":{"login":"jlitzingerdev","id":1496650,"avatar_url":"https://avatars3.githubusercontent.com/u/1496650?v=3","gravatar_id":"","url":"https://api.github.com/users/jlitzingerdev","html_url":"https://github.com/jlitzingerdev","followers_url":"https://api.github.com/users/jlitzingerdev/followers","following_url":"https://api.github.com/users/jlitzingerdev/following{/other_user}","gists_url":"https://api.github.com/users/jlitzingerdev/gists{/gist_id}","starred_url":"https://api.github.com/users/jlitzingerdev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jlitzingerdev/subscriptions","organizations_url":"https://api.github.com/users/jlitzingerdev/orgs","repos_url":"https://api.github.com/users/jlitzingerdev/repos","events_url":"https://api.github.com/users/jlitzingerdev/events{/privacy}","received_events_url":"https://api.github.com/users/jlitzingerdev/received_events","type":"User","site_admin":false},"repo":{"id":91534675,"name":"twisted","full_name":"jlitzingerdev/twisted","owner":{"login":"jlitzingerdev","id":1496650,"avatar_url":"https://avatars3.githubusercontent.com/u/1496650?v=3","gravatar_id":"","url":"https://api.github.com/users/jlitzingerdev","html_url":"https://github.com/jlitzingerdev","followers_url":"https://api.github.com/users/jlitzingerdev/followers","following_url":"https://api.github.com/users/jlitzingerdev/following{/other_user}","gists_url":"https://api.github.com/users/jlitzingerdev/gists{/gist_id}","starred_url":"https://api.github.com/users/jlitzingerdev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jlitzingerdev/subscriptions","organizations_url":"https://api.github.com/users/jlitzingerdev/orgs","repos_url":"https://api.github.com/users/jlitzingerdev/repos","events_url":"https://api.github.com/users/jlitzingerdev/events{/privacy}","received_events_url":"https://api.github.com/users/jlitzingerdev/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jlitzingerdev/twisted","description":"Event-driven networking engine written in Python.","fork":true,"url":"https://api.github.com/repos/jlitzingerdev/twisted","forks_url":"https://api.github.com/repos/jlitzingerdev/twisted/forks","keys_url":"https://api.github.com/repos/jlitzingerdev/twisted/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jlitzingerdev/twisted/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jlitzingerdev/twisted/teams","hooks_url":"https://api.github.com/repos/jlitzingerdev/twisted/hooks","issue_events_url":"https://api.github.com/repos/jlitzingerdev/twisted/issues/events{/number}","events_url":"https://api.github.com/repos/jlitzingerdev/twisted/events","assignees_url":"https://api.github.com/repos/jlitzingerdev/twisted/assignees{/user}","branches_url":"https://api.github.com/repos/jlitzingerdev/twisted/branches{/branch}","tags_url":"https://api.github.com/repos/jlitzingerdev/twisted/tags","blobs_url":"https://api.github.com/repos/jlitzingerdev/twisted/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jlitzingerdev/twisted/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jlitzingerdev/twisted/git/refs{/sha}","trees_url":"https://api.github.com/repos/jlitzingerdev/twisted/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jlitzingerdev/twisted/statuses/{sha}","languages_url":"https://api.github.com/repos/jlitzingerdev/twisted/languages","stargazers_url":"https://api.github.com/repos/jlitzingerdev/twisted/stargazers","contributors_url":"https://api.github.com/repos/jlitzingerdev/twisted/contributors","subscribers_url":"https://api.github.com/repos/jlitzingerdev/twisted/subscribers","subscription_url":"https://api.github.com/repos/jlitzingerdev/twisted/subscription","commits_url":"https://api.github.com/repos/jlitzingerdev/twisted/commits{/sha}","git_commits_url":"https://api.github.com/repos/jlitzingerdev/twisted/git/commits{/sha}","comments_url":"https://api.github.com/repos/jlitzingerdev/twisted/comments{/number}","issue_comment_url":"https://api.github.com/repos/jlitzingerdev/twisted/issues/comments{/number}","contents_url":"https://api.github.com/repos/jlitzingerdev/twisted/contents/{+path}","compare_url":"https://api.github.com/repos/jlitzingerdev/twisted/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jlitzingerdev/twisted/merges","archive_url":"https://api.github.com/repos/jlitzingerdev/twisted/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jlitzingerdev/twisted/downloads","issues_url":"https://api.github.com/repos/jlitzingerdev/twisted/issues{/number}","pulls_url":"https://api.github.com/repos/jlitzingerdev/twisted/pulls{/number}","milestones_url":"https://api.github.com/repos/jlitzingerdev/twisted/milestones{/number}","notifications_url":"https://api.github.com/repos/jlitzingerdev/twisted/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jlitzingerdev/twisted/labels{/name}","releases_url":"https://api.github.com/repos/jlitzingerdev/twisted/releases{/id}","deployments_url":"https://api.github.com/repos/jlitzingerdev/twisted/deployments","created_at":"2017-05-17T04:50:17Z","updated_at":"2017-05-17T04:50:30Z","pushed_at":"2017-07-04T04:44:15Z","git_url":"git://github.com/jlitzingerdev/twisted.git","ssh_url":"git@github.com:jlitzingerdev/twisted.git","clone_url":"https://github.com/jlitzingerdev/twisted.git","svn_url":"https://github.com/jlitzingerdev/twisted","homepage":"https://www.twistedmatrix.com","size":55630,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"trunk"}},"base":{"label":"twisted:trunk","ref":"trunk","sha":"cd868a99815bf9c96bed2a1a91f7cc3eef14c03b","user":{"login":"twisted","id":716546,"avatar_url":"https://avatars0.githubusercontent.com/u/716546?v=3","gravatar_id":"","url":"https://api.github.com/users/twisted","html_url":"https://github.com/twisted","followers_url":"https://api.github.com/users/twisted/followers","following_url":"https://api.github.com/users/twisted/following{/other_user}","gists_url":"https://api.github.com/users/twisted/gists{/gist_id}","starred_url":"https://api.github.com/users/twisted/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/twisted/subscriptions","organizations_url":"https://api.github.com/users/twisted/orgs","repos_url":"https://api.github.com/users/twisted/repos","events_url":"https://api.github.com/users/twisted/events{/privacy}","received_events_url":"https://api.github.com/users/twisted/received_events","type":"Organization","site_admin":false},"repo":{"id":1985358,"name":"twisted","full_name":"twisted/twisted","owner":{"login":"twisted","id":716546,"avatar_url":"https://avatars0.githubusercontent.com/u/716546?v=3","gravatar_id":"","url":"https://api.github.com/users/twisted","html_url":"https://github.com/twisted","followers_url":"https://api.github.com/users/twisted/followers","following_url":"https://api.github.com/users/twisted/following{/other_user}","gists_url":"https://api.github.com/users/twisted/gists{/gist_id}","starred_url":"https://api.github.com/users/twisted/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/twisted/subscriptions","organizations_url":"https://api.github.com/users/twisted/orgs","repos_url":"https://api.github.com/users/twisted/repos","events_url":"https://api.github.com/users/twisted/events{/privacy}","received_events_url":"https://api.github.com/users/twisted/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/twisted/twisted","description":"Event-driven networking engine written in Python.","fork":false,"url":"https://api.github.com/repos/twisted/twisted","forks_url":"https://api.github.com/repos/twisted/twisted/forks","keys_url":"https://api.github.com/repos/twisted/twisted/keys{/key_id}","collaborators_url":"https://api.github.com/repos/twisted/twisted/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/twisted/twisted/teams","hooks_url":"https://api.github.com/repos/twisted/twisted/hooks","issue_events_url":"https://api.github.com/repos/twisted/twisted/issues/events{/number}","events_url":"https://api.github.com/repos/twisted/twisted/events","assignees_url":"https://api.github.com/repos/twisted/twisted/assignees{/user}","branches_url":"https://api.github.com/repos/twisted/twisted/branches{/branch}","tags_url":"https://api.github.com/repos/twisted/twisted/tags","blobs_url":"https://api.github.com/repos/twisted/twisted/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/twisted/twisted/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/twisted/twisted/git/refs{/sha}","trees_url":"https://api.github.com/repos/twisted/twisted/git/trees{/sha}","statuses_url":"https://api.github.com/repos/twisted/twisted/statuses/{sha}","languages_url":"https://api.github.com/repos/twisted/twisted/languages","stargazers_url":"https://api.github.com/repos/twisted/twisted/stargazers","contributors_url":"https://api.github.com/repos/twisted/twisted/contributors","subscribers_url":"https://api.github.com/repos/twisted/twisted/subscribers","subscription_url":"https://api.github.com/repos/twisted/twisted/subscription","commits_url":"https://api.github.com/repos/twisted/twisted/commits{/sha}","git_commits_url":"https://api.github.com/repos/twisted/twisted/git/commits{/sha}","comments_url":"https://api.github.com/repos/twisted/twisted/comments{/number}","issue_comment_url":"https://api.github.com/repos/twisted/twisted/issues/comments{/number}","contents_url":"https://api.github.com/repos/twisted/twisted/contents/{+path}","compare_url":"https://api.github.com/repos/twisted/twisted/compare/{base}...{head}","merges_url":"https://api.github.com/repos/twisted/twisted/merges","archive_url":"https://api.github.com/repos/twisted/twisted/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/twisted/twisted/downloads","issues_url":"https://api.github.com/repos/twisted/twisted/issues{/number}","pulls_url":"https://api.github.com/repos/twisted/twisted/pulls{/number}","milestones_url":"https://api.github.com/repos/twisted/twisted/milestones{/number}","notifications_url":"https://api.github.com/repos/twisted/twisted/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/twisted/twisted/labels{/name}","releases_url":"https://api.github.com/repos/twisted/twisted/releases{/id}","deployments_url":"https://api.github.com/repos/twisted/twisted/deployments","created_at":"2011-07-01T20:40:42Z","updated_at":"2017-07-08T03:17:04Z","pushed_at":"2017-07-07T20:39:28Z","git_url":"git://github.com/twisted/twisted.git","ssh_url":"git@github.com:twisted/twisted.git","clone_url":"https://github.com/twisted/twisted.git","svn_url":"https://github.com/twisted/twisted","homepage":"https://www.twistedmatrix.com","size":55971,"stargazers_count":2037,"watchers_count":2037,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":617,"mirror_url":null,"open_issues_count":70,"forks":617,"open_issues":70,"watchers":2037,"default_branch":"trunk"}},"_links":{"self":{"href":"https://api.github.com/repos/twisted/twisted/pulls/826"},"html":{"href":"https://github.com/twisted/twisted/pull/826"},"issue":{"href":"https://api.github.com/repos/twisted/twisted/issues/826"},"comments":{"href":"https://api.github.com/repos/twisted/twisted/issues/826/comments"},"review_comments":{"href":"https://api.github.com/repos/twisted/twisted/pulls/826/comments"},"review_comment":{"href":"https://api.github.com/repos/twisted/twisted/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/twisted/twisted/pulls/826/commits"},"statuses":{"href":"https://api.github.com/repos/twisted/twisted/statuses/add82a87be83592b26ea21bcdae47b6b55144f91"}}}}
{"actor":{"display_login":"glyph"}}