{"action":"created","comment":{"url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/pulls/comments/66775908","id":66775908,"diff_hunk":"@@ -0,0 +1,102 @@\n+import unittest\n+import os\n+import pyinotify\n+import tempfile\n+import shutil\n+\n+event_holder = []\n+\n+\n+class processor(pyinotify.ProcessEvent):\n+    def process_default(self, event):\n+        event_holder.append(event)\n+\n+\n+class TestPyinotifyEvents(unittest.TestCase):\n+\n+    def setUp(self):\n+        del event_holder[:]\n+        self.watch_directory = tempfile.mkdtemp()\n+        wm = pyinotify.WatchManager()\n+        wm.add_watch(self.watch_directory, pyinotify.ALL_EVENTS)\n+        self.notifier = pyinotify.Notifier(wm, processor())\n+\n+    def tearDown(self):\n+        shutil.rmtree(self.watch_directory)\n+\n+    def _print_events(self):\n+        for e in event_holder:\n+            print(e.pathname, e.maskname)\n+\n+    def _get_events(self):\n+        self.notifier.read_events()\n+        self.notifier.process_events()\n+\n+    def _check_events(self, expected):\n+        for i, mask in enumerate(expected):\n+            self.assertEqual(mask, event_holder[i].mask)\n+\n+    def test_create_event(self):\n+        filename = os.path.join(self.watch_directory, \"tmp\")\n+        open(filename, \"w\").write(\"\")\n+        self._get_events()\n+        self._check_events([pyinotify.IN_CREATE,\n+                            pyinotify.IN_OPEN,\n+                            pyinotify.IN_CLOSE_WRITE])\n+\n+    def test_move_event(self):\n+        filename = os.path.join(self.watch_directory, \"tmp\")\n+        second_dir = tempfile.mkdtemp()\n+        filename2 = os.path.join(second_dir, \"tmp\")\n+        open(filename, \"w\").write(\"\")\n+\n+        #Move file out of directory\n+        shutil.move(filename, filename2)\n+        self._get_events()\n+        self.assertEqual(pyinotify.IN_MOVED_FROM, event_holder[-1].mask)\n+\n+        del event_holder[:]\n+\n+        #Move file into directory\n+        shutil.move(filename2, filename)\n+        self._get_events()\n+        self.assertEqual(pyinotify.IN_MOVED_TO, event_holder[-1].mask)\n+\n+        del event_holder[:]\n+\n+        #Move file within directory\n+        filename3 = os.path.join(self.watch_directory, \"tmp2\")\n+        shutil.move(filename, filename3)\n+        self._get_events()\n+\n+        self._check_events([pyinotify.IN_MOVED_FROM, pyinotify.IN_MOVED_TO])\n+        self.assertEqual(filename, event_holder[0].pathname)\n+        self.assertEqual(filename3, event_holder[1].pathname)\n+\n+    def test_modify_events(self):\n+        filename = os.path.join(self.watch_directory, \"tmp\")\n+        open(filename, \"w\").write(\"\")\n+        self._get_events()\n+        del event_holder[:]\n+\n+        open(filename, \"a\").write(\"foo\")\n+\n+        self._get_events()\n+        self._check_events([pyinotify.IN_OPEN,\n+                            pyinotify.IN_MODIFY,\n+                            pyinotify.IN_CLOSE_WRITE])\n+\n+    def test_delete_event(self):\n+        filename = os.path.join(self.watch_directory, \"tmp\")\n+        open(filename, \"w\").write(\"\")\n+        self._get_events()\n+        del event_holder[:]\n+\n+        os.remove(filename)\n+        self._get_events()\n+\n+        self._print_events()","path":"python3/tests.py","position":98,"original_position":98,"commit_id":"b1746313998faf9553db6bbeecc19088878542f2","original_commit_id":"b1746313998faf9553db6bbeecc19088878542f2","user":{"login":"alexdias","id":997142,"avatar_url":"https://avatars.githubusercontent.com/u/997142?v=3","gravatar_id":"","url":"https://api.github.com/users/alexdias","html_url":"https://github.com/alexdias","followers_url":"https://api.github.com/users/alexdias/followers","following_url":"https://api.github.com/users/alexdias/following{/other_user}","gists_url":"https://api.github.com/users/alexdias/gists{/gist_id}","starred_url":"https://api.github.com/users/alexdias/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexdias/subscriptions","organizations_url":"https://api.github.com/users/alexdias/orgs","repos_url":"https://api.github.com/users/alexdias/repos","events_url":"https://api.github.com/users/alexdias/events{/privacy}","received_events_url":"https://api.github.com/users/alexdias/received_events","type":"User","site_admin":false},"body":"Ah, cool","created_at":"2016-06-13T11:21:07Z","updated_at":"2016-06-13T11:21:07Z","html_url":"https://github.com/smarkets/pyinotify-smarkets/pull/1#discussion_r66775908","pull_request_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/smarkets/pyinotify-smarkets/pulls/comments/66775908"},"html":{"href":"https://github.com/smarkets/pyinotify-smarkets/pull/1#discussion_r66775908"},"pull_request":{"href":"https://api.github.com/repos/smarkets/pyinotify-smarkets/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/pulls/1","id":73555182,"html_url":"https://github.com/smarkets/pyinotify-smarkets/pull/1","diff_url":"https://github.com/smarkets/pyinotify-smarkets/pull/1.diff","patch_url":"https://github.com/smarkets/pyinotify-smarkets/pull/1.patch","issue_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/issues/1","number":1,"state":"open","locked":false,"title":"Provide Python 3 variant of the tests","user":{"login":"jstasiak","id":36209,"avatar_url":"https://avatars.githubusercontent.com/u/36209?v=3","gravatar_id":"","url":"https://api.github.com/users/jstasiak","html_url":"https://github.com/jstasiak","followers_url":"https://api.github.com/users/jstasiak/followers","following_url":"https://api.github.com/users/jstasiak/following{/other_user}","gists_url":"https://api.github.com/users/jstasiak/gists{/gist_id}","starred_url":"https://api.github.com/users/jstasiak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jstasiak/subscriptions","organizations_url":"https://api.github.com/users/jstasiak/orgs","repos_url":"https://api.github.com/users/jstasiak/repos","events_url":"https://api.github.com/users/jstasiak/events{/privacy}","received_events_url":"https://api.github.com/users/jstasiak/received_events","type":"User","site_admin":false},"body":"This file is just Python 2 tests with one change to a print statement.","created_at":"2016-06-13T10:43:44Z","updated_at":"2016-06-13T11:21:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4068fc8c1b187ea98b323d3f46646f97c0bcb08d","assignee":{"login":"alexdias","id":997142,"avatar_url":"https://avatars.githubusercontent.com/u/997142?v=3","gravatar_id":"","url":"https://api.github.com/users/alexdias","html_url":"https://github.com/alexdias","followers_url":"https://api.github.com/users/alexdias/followers","following_url":"https://api.github.com/users/alexdias/following{/other_user}","gists_url":"https://api.github.com/users/alexdias/gists{/gist_id}","starred_url":"https://api.github.com/users/alexdias/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexdias/subscriptions","organizations_url":"https://api.github.com/users/alexdias/orgs","repos_url":"https://api.github.com/users/alexdias/repos","events_url":"https://api.github.com/users/alexdias/events{/privacy}","received_events_url":"https://api.github.com/users/alexdias/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/pulls/1/commits","review_comments_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/pulls/1/comments","review_comment_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/pulls/comments{/number}","comments_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/issues/1/comments","statuses_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/statuses/b1746313998faf9553db6bbeecc19088878542f2","head":{"label":"smarkets:python3-tests","ref":"python3-tests","sha":"b1746313998faf9553db6bbeecc19088878542f2","user":{"login":"smarkets","id":86334,"avatar_url":"https://avatars.githubusercontent.com/u/86334?v=3","gravatar_id":"","url":"https://api.github.com/users/smarkets","html_url":"https://github.com/smarkets","followers_url":"https://api.github.com/users/smarkets/followers","following_url":"https://api.github.com/users/smarkets/following{/other_user}","gists_url":"https://api.github.com/users/smarkets/gists{/gist_id}","starred_url":"https://api.github.com/users/smarkets/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smarkets/subscriptions","organizations_url":"https://api.github.com/users/smarkets/orgs","repos_url":"https://api.github.com/users/smarkets/repos","events_url":"https://api.github.com/users/smarkets/events{/privacy}","received_events_url":"https://api.github.com/users/smarkets/received_events","type":"Organization","site_admin":false},"repo":{"id":49197187,"name":"pyinotify-smarkets","full_name":"smarkets/pyinotify-smarkets","owner":{"login":"smarkets","id":86334,"avatar_url":"https://avatars.githubusercontent.com/u/86334?v=3","gravatar_id":"","url":"https://api.github.com/users/smarkets","html_url":"https://github.com/smarkets","followers_url":"https://api.github.com/users/smarkets/followers","following_url":"https://api.github.com/users/smarkets/following{/other_user}","gists_url":"https://api.github.com/users/smarkets/gists{/gist_id}","starred_url":"https://api.github.com/users/smarkets/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smarkets/subscriptions","organizations_url":"https://api.github.com/users/smarkets/orgs","repos_url":"https://api.github.com/users/smarkets/repos","events_url":"https://api.github.com/users/smarkets/events{/privacy}","received_events_url":"https://api.github.com/users/smarkets/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/smarkets/pyinotify-smarkets","description":"Monitoring filesystems events with inotify on Linux.","fork":true,"url":"https://api.github.com/repos/smarkets/pyinotify-smarkets","forks_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/forks","keys_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/keys{/key_id}","collaborators_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/teams","hooks_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/hooks","issue_events_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/issues/events{/number}","events_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/events","assignees_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/assignees{/user}","branches_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/branches{/branch}","tags_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/tags","blobs_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/git/refs{/sha}","trees_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/git/trees{/sha}","statuses_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/statuses/{sha}","languages_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/languages","stargazers_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/stargazers","contributors_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/contributors","subscribers_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/subscribers","subscription_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/subscription","commits_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/commits{/sha}","git_commits_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/git/commits{/sha}","comments_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/comments{/number}","issue_comment_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/issues/comments{/number}","contents_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/contents/{+path}","compare_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/compare/{base}...{head}","merges_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/merges","archive_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/downloads","issues_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/issues{/number}","pulls_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/pulls{/number}","milestones_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/milestones{/number}","notifications_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/labels{/name}","releases_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/releases{/id}","deployments_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/deployments","created_at":"2016-01-07T10:11:15Z","updated_at":"2016-06-11T10:46:01Z","pushed_at":"2016-06-13T10:48:18Z","git_url":"git://github.com/smarkets/pyinotify-smarkets.git","ssh_url":"git@github.com:smarkets/pyinotify-smarkets.git","clone_url":"https://github.com/smarkets/pyinotify-smarkets.git","svn_url":"https://github.com/smarkets/pyinotify-smarkets","homepage":"http://github.com/seb-m/pyinotify/wiki","size":3798,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"smarkets:master","ref":"master","sha":"fdb18c1031eeb0789cb968bd9cbe3d0988357a25","user":{"login":"smarkets","id":86334,"avatar_url":"https://avatars.githubusercontent.com/u/86334?v=3","gravatar_id":"","url":"https://api.github.com/users/smarkets","html_url":"https://github.com/smarkets","followers_url":"https://api.github.com/users/smarkets/followers","following_url":"https://api.github.com/users/smarkets/following{/other_user}","gists_url":"https://api.github.com/users/smarkets/gists{/gist_id}","starred_url":"https://api.github.com/users/smarkets/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smarkets/subscriptions","organizations_url":"https://api.github.com/users/smarkets/orgs","repos_url":"https://api.github.com/users/smarkets/repos","events_url":"https://api.github.com/users/smarkets/events{/privacy}","received_events_url":"https://api.github.com/users/smarkets/received_events","type":"Organization","site_admin":false},"repo":{"id":49197187,"name":"pyinotify-smarkets","full_name":"smarkets/pyinotify-smarkets","owner":{"login":"smarkets","id":86334,"avatar_url":"https://avatars.githubusercontent.com/u/86334?v=3","gravatar_id":"","url":"https://api.github.com/users/smarkets","html_url":"https://github.com/smarkets","followers_url":"https://api.github.com/users/smarkets/followers","following_url":"https://api.github.com/users/smarkets/following{/other_user}","gists_url":"https://api.github.com/users/smarkets/gists{/gist_id}","starred_url":"https://api.github.com/users/smarkets/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smarkets/subscriptions","organizations_url":"https://api.github.com/users/smarkets/orgs","repos_url":"https://api.github.com/users/smarkets/repos","events_url":"https://api.github.com/users/smarkets/events{/privacy}","received_events_url":"https://api.github.com/users/smarkets/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/smarkets/pyinotify-smarkets","description":"Monitoring filesystems events with inotify on Linux.","fork":true,"url":"https://api.github.com/repos/smarkets/pyinotify-smarkets","forks_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/forks","keys_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/keys{/key_id}","collaborators_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/teams","hooks_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/hooks","issue_events_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/issues/events{/number}","events_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/events","assignees_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/assignees{/user}","branches_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/branches{/branch}","tags_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/tags","blobs_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/git/refs{/sha}","trees_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/git/trees{/sha}","statuses_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/statuses/{sha}","languages_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/languages","stargazers_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/stargazers","contributors_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/contributors","subscribers_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/subscribers","subscription_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/subscription","commits_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/commits{/sha}","git_commits_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/git/commits{/sha}","comments_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/comments{/number}","issue_comment_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/issues/comments{/number}","contents_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/contents/{+path}","compare_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/compare/{base}...{head}","merges_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/merges","archive_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/downloads","issues_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/issues{/number}","pulls_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/pulls{/number}","milestones_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/milestones{/number}","notifications_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/labels{/name}","releases_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/releases{/id}","deployments_url":"https://api.github.com/repos/smarkets/pyinotify-smarkets/deployments","created_at":"2016-01-07T10:11:15Z","updated_at":"2016-06-11T10:46:01Z","pushed_at":"2016-06-13T10:48:18Z","git_url":"git://github.com/smarkets/pyinotify-smarkets.git","ssh_url":"git@github.com:smarkets/pyinotify-smarkets.git","clone_url":"https://github.com/smarkets/pyinotify-smarkets.git","svn_url":"https://github.com/smarkets/pyinotify-smarkets","homepage":"http://github.com/seb-m/pyinotify/wiki","size":3798,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/smarkets/pyinotify-smarkets/pulls/1"},"html":{"href":"https://github.com/smarkets/pyinotify-smarkets/pull/1"},"issue":{"href":"https://api.github.com/repos/smarkets/pyinotify-smarkets/issues/1"},"comments":{"href":"https://api.github.com/repos/smarkets/pyinotify-smarkets/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/smarkets/pyinotify-smarkets/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/smarkets/pyinotify-smarkets/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/smarkets/pyinotify-smarkets/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/smarkets/pyinotify-smarkets/statuses/b1746313998faf9553db6bbeecc19088878542f2"}}}}
{"actor":{"display_login":"alexdias"}}