-
Notifications
You must be signed in to change notification settings - Fork 47
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
feat(strptime):handle %b and %B directive. #121
Conversation
Thanks @Mojtaba-saf, Please add some tests for this path. |
Let's add another test for invalid month name: def test_strptime_invalid_date_string_b_B_directive(self):
with self.assertRaises(
ValueError,
msg="time data '14 foo 1400' does not match format '%d %b %Y'"
):
jdatetime.datetime.strptime('14 foo 1400', '%d %b %Y') |
Co-authored-by: Hasan Ramezani <hasan.r67@gmail.com>
sorry I'm not familiar with writing test cases. should this test for invalid month name be exactly like what you said or should it be like the last one and contain multiple subtests? |
I would add it to a separate test function.
Yes, you can another test case for def test_strptime_b_B_directive_invalid_month(self):
tests = (
('۱4 foo 14۰0', '%d %B %Y'),
('۱4 bar 14۰0', '%d %b %Y'),
)
for date_string, date_format in tests:
with self.subTest(date_string=date_string, date_format=date_format):
with self.assertRaises(
ValueError,
msg=f"time data '{date_string}' does not match format '{date_format}'"
):
jdatetime.datetime.strptime(date_string, date_format) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Mojtaba-saf 👍
Thanks @Mojtaba-saf ❤️ |
in response to this issue
as I discussed there If patterns are changed to use '\d' instead of [0-9] regex patterns for python 3 can detect Unicode numbers.
to detect month names in the string we can use these patterns.
these patterns detect month names.
I tested it against these examples and it works fine.