Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse Monday #1121

Merged
merged 2 commits into from
Jan 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion dateparser/data/date_translation_data/en.py
Expand Up @@ -93,7 +93,6 @@
"month": [
"mo",
"month",
"mon",
"months"
],
"week": [
Expand Down
Expand Up @@ -16,7 +16,6 @@ year:
- y
- years
month:
- mon
- months
week:
- weeks
Expand Down
2 changes: 2 additions & 0 deletions tests/test_date_parser.py
Expand Up @@ -497,6 +497,7 @@ def test_dates_not_parsed(self, date_string, message):
param('March', datetime(2014, 3, 15)),
param('Friday', datetime(2015, 2, 13)),
param('Monday', datetime(2015, 2, 9)),
param('Mon', datetime(2015, 2, 9)),
param('Sunday', datetime(2015, 2, 8)), # current day
param('10:00PM', datetime(2015, 2, 14, 22, 0)),
param('16:10', datetime(2015, 2, 14, 16, 10)),
Expand Down Expand Up @@ -759,6 +760,7 @@ def test_period_is_time_if_return_time_as_period_setting_applied_and_time_compon
@parameterized.expand([
param('16:00', expected=datetime(2018, 12, 13, 16, 0), period='time'),
param('Monday 7:15 AM', expected=datetime(2018, 12, 10, 7, 15), period='time'),
param('Mon 19:43', expected=datetime(2018, 12, 10, 19, 43), period='time'),
])
def test_period_is_time_if_return_time_as_period_and_relative_base_settings_applied_and_time_component_present(
self, date_string, expected=None, period=None
Expand Down
11 changes: 10 additions & 1 deletion tests/test_freshness_date_parser.py
Expand Up @@ -97,7 +97,6 @@ def test_relative_past_dates_with_time_as_period(self, date_string, ago, period)
param('nine hours ago', ago={'hours': 9}, period='day'),
param('three week ago', ago={'weeks': 3}, period='week'),
param('eight months ago', ago={'months': 8}, period='month'),
param('1mon ago', ago={'months': 1}, period='month'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to how there is test_insane_dates and test_dates_not_supported_by_date_time, we could add a test_known_issues that keeps this test case around but expects it to fail, and include a comment pointing to the issue that caused us to break it.

(I thought we were using pytest’s parametrize when I suggested marking this line as an expected failure)

param('six days ago', ago={'days': 6}, period='day'),
param('five years ago', ago={'years': 5}, period='year'),
param('2y ago', ago={'years': 2}, period='year'),
Expand Down Expand Up @@ -1518,6 +1517,16 @@ def test_dates_not_supported_by_date_time(self, date_string):
self.then_error_was_not_raised()
self.assertEqual(None, self.result['date_obj'])

@parameterized.expand([
param('1mon ago'), #1116
])
def test_known_issues(self, date_string):
self.given_parser()
self.given_date_string(date_string)
self.when_date_is_parsed()
self.then_error_was_not_raised()
self.assertEqual(None, self.result['date_obj'])

@parameterized.expand([
param('несколько секунд назад', boundary={'seconds': 45}, period='day'),
param('há alguns segundos', boundary={'seconds': 45}, period='day'),
Expand Down