{"action":"created","comment":{"url":"https://api.github.com/repos/scrapinghub/dateparser/pulls/comments/26406639","id":26406639,"diff_hunk":"@@ -2,66 +2,138 @@\n # -*- coding: utf-8 -*-\n from __future__ import unicode_literals\n \n+from types import MethodType\n+from itertools import izip\n+from collections import OrderedDict\n import unittest\n from datetime import datetime, timedelta\n \n from dateutil.relativedelta import relativedelta\n+\n from mock import Mock, patch\n+\n from nose_parameterized import parameterized, param\n \n+from dateparser.languages import LanguageDataLoader\n from dateparser import date\n from tests import BaseTestCase\n \n \n-class DateRangeTest(unittest.TestCase):\n+class DateRangeTest(BaseTestCase):\n+    def setUp(self):\n+        super(DateRangeTest, self).setUp()\n+        self.period_start = NotImplemented\n+        self.period_end = NotImplemented\n \n-    def test_should_render_10_days_range(self):\n-        begin = datetime(2014, 6, 15)\n-        end = datetime(2014, 6, 25)\n-        dates = list(date.date_range(begin, end))\n-        self.assertEquals(10, len(dates))\n-        self.assertEquals(begin, dates[0])\n-        self.assertEquals(end - timedelta(days=1), dates[-1])\n+    @parameterized.expand([\n+        param(begin=datetime(2014, 6, 15), end=datetime(2014, 6, 25), expected_length=10)\n+    ])\n+    def test_date_range(self, begin, end, expected_length):\n+        self.given_period_start(begin)\n+        self.given_period_end(end)\n+        self.when_date_range_generated()\n+        self.then_range_length_is(expected_length)\n+        self.then_all_dates_are_present_in_range()\n+        self.then_range_is_in_ascending_order()\n \n-    def test_should_one_date_for_each_month(self):\n-        fixtures = [\n-            (datetime(2014, 4, 15), datetime(2014, 6, 25),\n-             [(2014, 4), (2014, 5), (2014, 6)]),\n+    @parameterized.expand([\n+        param(begin=datetime(2014, 4, 15),\n+              end=datetime(2014, 6, 25),\n+              expected_months=[(2014, 4), (2014, 5), (2014, 6)]),\n+        param(begin=datetime(2014, 4, 25),\n+              end=datetime(2014, 5, 5),\n+              expected_months=[(2014, 4), (2014, 5)]),\n+        param(begin=datetime(2014, 4, 5),\n+              end=datetime(2014, 4, 25),\n+              expected_months=[(2014, 4)]),\n+        param(begin=datetime(2014, 4, 25),\n+              end=datetime(2014, 6, 5),\n+              expected_months=[(2014, 4), (2014, 5), (2014, 6)]),\n+    ])\n+    def test_one_date_for_each_month(self, begin, end, expected_months):\n+        self.given_period_start(begin)\n+        self.given_period_end(end)\n+        self.given_period_size(months=1)\n+        self.when_month_range_generated()\n+        self.then_expected_months_are(expected_months)\n \n-            (datetime(2014, 4, 25), datetime(2014, 5, 5),\n-             [(2014, 4), (2014, 5)]),\n+    @parameterized.expand([\n+        'year',\n+        'month',\n+        'week',\n+        'day',\n+        'hour',\n+        'minute',\n+        'second',\n+    ])\n+    def test_should_reject_easily_mistaken_dateutil_arguments(self, invalid_period):\n+        self.given_period_start(datetime(2014, 6, 15))\n+        self.given_period_end(datetime(2014, 6, 25))\n+        self.given_period_size(**{invalid_period: 1})\n+        self.when_period_is_parsed()\n+        self.then_period_was_rejected(invalid_period)\n \n-            (datetime(2014, 4, 5), datetime(2014, 4, 25),\n-             [(2014, 4)]),\n+    def given_period_start(self, begin):\n+        self.period_start = begin\n \n-            (datetime(2014, 4, 25), datetime(2014, 6, 5),\n-             [(2014, 4), (2014, 5), (2014, 6)]),\n-        ]\n+    def given_period_end(self, end):\n+        self.period_end = end\n \n-        for begin, end, expected in fixtures:\n-            result = list(date.date_range(begin, end, months=1))\n-            self.assertEquals(expected,\n-                              [(d.year, d.month) for d in result])\n+    def given_period_size(self, **params):\n+        self.period_size = params\n \n-    def test_should_reject_easily_mistaken_dateutil_arguments(self):\n-        begin = datetime(2014, 6, 15)\n-        end = datetime(2014, 6, 25)\n+    def when_month_range_generated(self):\n+        self.generated_months = list(date.date_range(self.period_start, self.period_end, **self.period_size))\n+\n+    def when_date_range_generated(self):\n+        self.range = list(date.date_range(self.period_start, self.period_end))\n+\n+    def when_period_is_parsed(self):\n+        try:\n+            self.result = date.date_range(self.period_start, self.period_end, **self.period_size).next()\n+        except Exception as error:\n+            self.result = error\n+        finally:\n+            self.results = self.result","path":"tests/test_date.py","position":122,"original_position":122,"commit_id":"99b42d3070cd751b2e630266c728f7608e0f0e13","original_commit_id":"99b42d3070cd751b2e630266c728f7608e0f0e13","user":{"login":"tsrdatatech","id":4684832,"avatar_url":"https://avatars.githubusercontent.com/u/4684832?v=3","gravatar_id":"","url":"https://api.github.com/users/tsrdatatech","html_url":"https://github.com/tsrdatatech","followers_url":"https://api.github.com/users/tsrdatatech/followers","following_url":"https://api.github.com/users/tsrdatatech/following{/other_user}","gists_url":"https://api.github.com/users/tsrdatatech/gists{/gist_id}","starred_url":"https://api.github.com/users/tsrdatatech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tsrdatatech/subscriptions","organizations_url":"https://api.github.com/users/tsrdatatech/orgs","repos_url":"https://api.github.com/users/tsrdatatech/repos","events_url":"https://api.github.com/users/tsrdatatech/events{/privacy}","received_events_url":"https://api.github.com/users/tsrdatatech/received_events","type":"User","site_admin":false},"body":"no actually ```self.result.message``` so I will remove that from the finally part of that code.","created_at":"2015-03-13T17:41:14Z","updated_at":"2015-03-13T17:41:14Z","html_url":"https://github.com/scrapinghub/dateparser/pull/56#discussion_r26406639","pull_request_url":"https://api.github.com/repos/scrapinghub/dateparser/pulls/56","_links":{"self":{"href":"https://api.github.com/repos/scrapinghub/dateparser/pulls/comments/26406639"},"html":{"href":"https://github.com/scrapinghub/dateparser/pull/56#discussion_r26406639"},"pull_request":{"href":"https://api.github.com/repos/scrapinghub/dateparser/pulls/56"}}},"pull_request":{"url":"https://api.github.com/repos/scrapinghub/dateparser/pulls/56","id":29283182,"html_url":"https://github.com/scrapinghub/dateparser/pull/56","diff_url":"https://github.com/scrapinghub/dateparser/pull/56.diff","patch_url":"https://github.com/scrapinghub/dateparser/pull/56.patch","issue_url":"https://api.github.com/repos/scrapinghub/dateparser/issues/56","number":56,"state":"open","locked":false,"title":"Implements issue #31","user":{"login":"tsrdatatech","id":4684832,"avatar_url":"https://avatars.githubusercontent.com/u/4684832?v=3","gravatar_id":"","url":"https://api.github.com/users/tsrdatatech","html_url":"https://github.com/tsrdatatech","followers_url":"https://api.github.com/users/tsrdatatech/followers","following_url":"https://api.github.com/users/tsrdatatech/following{/other_user}","gists_url":"https://api.github.com/users/tsrdatatech/gists{/gist_id}","starred_url":"https://api.github.com/users/tsrdatatech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tsrdatatech/subscriptions","organizations_url":"https://api.github.com/users/tsrdatatech/orgs","repos_url":"https://api.github.com/users/tsrdatatech/repos","events_url":"https://api.github.com/users/tsrdatatech/events{/privacy}","received_events_url":"https://api.github.com/users/tsrdatatech/received_events","type":"User","site_admin":false},"body":"Transformed code to a given-when-then approach.","created_at":"2015-02-13T17:33:39Z","updated_at":"2015-03-13T17:41:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"70b97db7114b3673fba463e3dffbaf4d4078b74c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/scrapinghub/dateparser/pulls/56/commits","review_comments_url":"https://api.github.com/repos/scrapinghub/dateparser/pulls/56/comments","review_comment_url":"https://api.github.com/repos/scrapinghub/dateparser/pulls/comments{/number}","comments_url":"https://api.github.com/repos/scrapinghub/dateparser/issues/56/comments","statuses_url":"https://api.github.com/repos/scrapinghub/dateparser/statuses/99b42d3070cd751b2e630266c728f7608e0f0e13","head":{"label":"tsrdatatech:uniform_unit_tests","ref":"uniform_unit_tests","sha":"99b42d3070cd751b2e630266c728f7608e0f0e13","user":{"login":"tsrdatatech","id":4684832,"avatar_url":"https://avatars.githubusercontent.com/u/4684832?v=3","gravatar_id":"","url":"https://api.github.com/users/tsrdatatech","html_url":"https://github.com/tsrdatatech","followers_url":"https://api.github.com/users/tsrdatatech/followers","following_url":"https://api.github.com/users/tsrdatatech/following{/other_user}","gists_url":"https://api.github.com/users/tsrdatatech/gists{/gist_id}","starred_url":"https://api.github.com/users/tsrdatatech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tsrdatatech/subscriptions","organizations_url":"https://api.github.com/users/tsrdatatech/orgs","repos_url":"https://api.github.com/users/tsrdatatech/repos","events_url":"https://api.github.com/users/tsrdatatech/events{/privacy}","received_events_url":"https://api.github.com/users/tsrdatatech/received_events","type":"User","site_admin":false},"repo":{"id":30245365,"name":"dateparser","full_name":"tsrdatatech/dateparser","owner":{"login":"tsrdatatech","id":4684832,"avatar_url":"https://avatars.githubusercontent.com/u/4684832?v=3","gravatar_id":"","url":"https://api.github.com/users/tsrdatatech","html_url":"https://github.com/tsrdatatech","followers_url":"https://api.github.com/users/tsrdatatech/followers","following_url":"https://api.github.com/users/tsrdatatech/following{/other_user}","gists_url":"https://api.github.com/users/tsrdatatech/gists{/gist_id}","starred_url":"https://api.github.com/users/tsrdatatech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tsrdatatech/subscriptions","organizations_url":"https://api.github.com/users/tsrdatatech/orgs","repos_url":"https://api.github.com/users/tsrdatatech/repos","events_url":"https://api.github.com/users/tsrdatatech/events{/privacy}","received_events_url":"https://api.github.com/users/tsrdatatech/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tsrdatatech/dateparser","description":"python parser for human readable dates","fork":true,"url":"https://api.github.com/repos/tsrdatatech/dateparser","forks_url":"https://api.github.com/repos/tsrdatatech/dateparser/forks","keys_url":"https://api.github.com/repos/tsrdatatech/dateparser/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tsrdatatech/dateparser/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tsrdatatech/dateparser/teams","hooks_url":"https://api.github.com/repos/tsrdatatech/dateparser/hooks","issue_events_url":"https://api.github.com/repos/tsrdatatech/dateparser/issues/events{/number}","events_url":"https://api.github.com/repos/tsrdatatech/dateparser/events","assignees_url":"https://api.github.com/repos/tsrdatatech/dateparser/assignees{/user}","branches_url":"https://api.github.com/repos/tsrdatatech/dateparser/branches{/branch}","tags_url":"https://api.github.com/repos/tsrdatatech/dateparser/tags","blobs_url":"https://api.github.com/repos/tsrdatatech/dateparser/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tsrdatatech/dateparser/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tsrdatatech/dateparser/git/refs{/sha}","trees_url":"https://api.github.com/repos/tsrdatatech/dateparser/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tsrdatatech/dateparser/statuses/{sha}","languages_url":"https://api.github.com/repos/tsrdatatech/dateparser/languages","stargazers_url":"https://api.github.com/repos/tsrdatatech/dateparser/stargazers","contributors_url":"https://api.github.com/repos/tsrdatatech/dateparser/contributors","subscribers_url":"https://api.github.com/repos/tsrdatatech/dateparser/subscribers","subscription_url":"https://api.github.com/repos/tsrdatatech/dateparser/subscription","commits_url":"https://api.github.com/repos/tsrdatatech/dateparser/commits{/sha}","git_commits_url":"https://api.github.com/repos/tsrdatatech/dateparser/git/commits{/sha}","comments_url":"https://api.github.com/repos/tsrdatatech/dateparser/comments{/number}","issue_comment_url":"https://api.github.com/repos/tsrdatatech/dateparser/issues/comments{/number}","contents_url":"https://api.github.com/repos/tsrdatatech/dateparser/contents/{+path}","compare_url":"https://api.github.com/repos/tsrdatatech/dateparser/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tsrdatatech/dateparser/merges","archive_url":"https://api.github.com/repos/tsrdatatech/dateparser/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tsrdatatech/dateparser/downloads","issues_url":"https://api.github.com/repos/tsrdatatech/dateparser/issues{/number}","pulls_url":"https://api.github.com/repos/tsrdatatech/dateparser/pulls{/number}","milestones_url":"https://api.github.com/repos/tsrdatatech/dateparser/milestones{/number}","notifications_url":"https://api.github.com/repos/tsrdatatech/dateparser/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tsrdatatech/dateparser/labels{/name}","releases_url":"https://api.github.com/repos/tsrdatatech/dateparser/releases{/id}","created_at":"2015-02-03T14:00:45Z","updated_at":"2015-02-03T14:00:46Z","pushed_at":"2015-03-12T20:25:34Z","git_url":"git://github.com/tsrdatatech/dateparser.git","ssh_url":"git@github.com:tsrdatatech/dateparser.git","clone_url":"https://github.com/tsrdatatech/dateparser.git","svn_url":"https://github.com/tsrdatatech/dateparser","homepage":"","size":421,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"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":"master"}},"base":{"label":"scrapinghub:master","ref":"master","sha":"7f60e017eaa99dea7c96f82a118ec4716c4c04d8","user":{"login":"scrapinghub","id":699596,"avatar_url":"https://avatars.githubusercontent.com/u/699596?v=3","gravatar_id":"","url":"https://api.github.com/users/scrapinghub","html_url":"https://github.com/scrapinghub","followers_url":"https://api.github.com/users/scrapinghub/followers","following_url":"https://api.github.com/users/scrapinghub/following{/other_user}","gists_url":"https://api.github.com/users/scrapinghub/gists{/gist_id}","starred_url":"https://api.github.com/users/scrapinghub/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scrapinghub/subscriptions","organizations_url":"https://api.github.com/users/scrapinghub/orgs","repos_url":"https://api.github.com/users/scrapinghub/repos","events_url":"https://api.github.com/users/scrapinghub/events{/privacy}","received_events_url":"https://api.github.com/users/scrapinghub/received_events","type":"Organization","site_admin":false},"repo":{"id":27086567,"name":"dateparser","full_name":"scrapinghub/dateparser","owner":{"login":"scrapinghub","id":699596,"avatar_url":"https://avatars.githubusercontent.com/u/699596?v=3","gravatar_id":"","url":"https://api.github.com/users/scrapinghub","html_url":"https://github.com/scrapinghub","followers_url":"https://api.github.com/users/scrapinghub/followers","following_url":"https://api.github.com/users/scrapinghub/following{/other_user}","gists_url":"https://api.github.com/users/scrapinghub/gists{/gist_id}","starred_url":"https://api.github.com/users/scrapinghub/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scrapinghub/subscriptions","organizations_url":"https://api.github.com/users/scrapinghub/orgs","repos_url":"https://api.github.com/users/scrapinghub/repos","events_url":"https://api.github.com/users/scrapinghub/events{/privacy}","received_events_url":"https://api.github.com/users/scrapinghub/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/scrapinghub/dateparser","description":"python parser for human readable dates","fork":false,"url":"https://api.github.com/repos/scrapinghub/dateparser","forks_url":"https://api.github.com/repos/scrapinghub/dateparser/forks","keys_url":"https://api.github.com/repos/scrapinghub/dateparser/keys{/key_id}","collaborators_url":"https://api.github.com/repos/scrapinghub/dateparser/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/scrapinghub/dateparser/teams","hooks_url":"https://api.github.com/repos/scrapinghub/dateparser/hooks","issue_events_url":"https://api.github.com/repos/scrapinghub/dateparser/issues/events{/number}","events_url":"https://api.github.com/repos/scrapinghub/dateparser/events","assignees_url":"https://api.github.com/repos/scrapinghub/dateparser/assignees{/user}","branches_url":"https://api.github.com/repos/scrapinghub/dateparser/branches{/branch}","tags_url":"https://api.github.com/repos/scrapinghub/dateparser/tags","blobs_url":"https://api.github.com/repos/scrapinghub/dateparser/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/scrapinghub/dateparser/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/scrapinghub/dateparser/git/refs{/sha}","trees_url":"https://api.github.com/repos/scrapinghub/dateparser/git/trees{/sha}","statuses_url":"https://api.github.com/repos/scrapinghub/dateparser/statuses/{sha}","languages_url":"https://api.github.com/repos/scrapinghub/dateparser/languages","stargazers_url":"https://api.github.com/repos/scrapinghub/dateparser/stargazers","contributors_url":"https://api.github.com/repos/scrapinghub/dateparser/contributors","subscribers_url":"https://api.github.com/repos/scrapinghub/dateparser/subscribers","subscription_url":"https://api.github.com/repos/scrapinghub/dateparser/subscription","commits_url":"https://api.github.com/repos/scrapinghub/dateparser/commits{/sha}","git_commits_url":"https://api.github.com/repos/scrapinghub/dateparser/git/commits{/sha}","comments_url":"https://api.github.com/repos/scrapinghub/dateparser/comments{/number}","issue_comment_url":"https://api.github.com/repos/scrapinghub/dateparser/issues/comments{/number}","contents_url":"https://api.github.com/repos/scrapinghub/dateparser/contents/{+path}","compare_url":"https://api.github.com/repos/scrapinghub/dateparser/compare/{base}...{head}","merges_url":"https://api.github.com/repos/scrapinghub/dateparser/merges","archive_url":"https://api.github.com/repos/scrapinghub/dateparser/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/scrapinghub/dateparser/downloads","issues_url":"https://api.github.com/repos/scrapinghub/dateparser/issues{/number}","pulls_url":"https://api.github.com/repos/scrapinghub/dateparser/pulls{/number}","milestones_url":"https://api.github.com/repos/scrapinghub/dateparser/milestones{/number}","notifications_url":"https://api.github.com/repos/scrapinghub/dateparser/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/scrapinghub/dateparser/labels{/name}","releases_url":"https://api.github.com/repos/scrapinghub/dateparser/releases{/id}","created_at":"2014-11-24T17:30:12Z","updated_at":"2015-03-11T21:15:30Z","pushed_at":"2015-03-11T21:15:29Z","git_url":"git://github.com/scrapinghub/dateparser.git","ssh_url":"git@github.com:scrapinghub/dateparser.git","clone_url":"https://github.com/scrapinghub/dateparser.git","svn_url":"https://github.com/scrapinghub/dateparser","homepage":"","size":1502,"stargazers_count":337,"watchers_count":337,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":26,"mirror_url":null,"open_issues_count":15,"forks":26,"open_issues":15,"watchers":337,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/scrapinghub/dateparser/pulls/56"},"html":{"href":"https://github.com/scrapinghub/dateparser/pull/56"},"issue":{"href":"https://api.github.com/repos/scrapinghub/dateparser/issues/56"},"comments":{"href":"https://api.github.com/repos/scrapinghub/dateparser/issues/56/comments"},"review_comments":{"href":"https://api.github.com/repos/scrapinghub/dateparser/pulls/56/comments"},"review_comment":{"href":"https://api.github.com/repos/scrapinghub/dateparser/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/scrapinghub/dateparser/pulls/56/commits"},"statuses":{"href":"https://api.github.com/repos/scrapinghub/dateparser/statuses/99b42d3070cd751b2e630266c728f7608e0f0e13"}}}}