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

Fix locale argument for factory.get() #631

Merged
merged 1 commit into from Aug 8, 2019
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
2 changes: 1 addition & 1 deletion arrow/factory.py
Expand Up @@ -150,7 +150,7 @@ def get(self, *args, **kwargs):
"""

arg_count = len(args)
locale = kwargs.get("locale", "en_us")
locale = kwargs.pop("locale", "en_us")
tz = kwargs.get("tzinfo", None)

# if kwargs given, send to constructor unless only tzinfo provided
Expand Down
16 changes: 10 additions & 6 deletions tests/factory_tests.py
Expand Up @@ -257,15 +257,19 @@ def test_insufficient_kwargs(self):
with self.assertRaises(TypeError):
self.factory.get(year=2016, month=7)

def test_locale_kwarg_only(self):
def test_locale(self):
result = self.factory.get("2010", "YYYY", locale="ja")
self.assertEqual(
result._datetime, datetime(2010, 1, 1, 0, 0, 0, 0, tzinfo=tz.tzutc())
)

with self.assertRaises(TypeError):
self.factory.get(locale="ja")
def test_locale_kwarg_only(self):
res = self.factory.get(locale="ja")
self.assertEqual(res.tzinfo, tz.tzutc())

def test_locale_with_tzinfo(self):

with self.assertRaises(TypeError):
self.factory.get(locale="ja", tzinfo=tz.gettz("Asia/Tokyo"))
res = self.factory.get(locale="ja", tzinfo=tz.gettz("Asia/Tokyo"))
self.assertEqual(res.tzinfo, tz.gettz("Asia/Tokyo"))


class UtcNowTests(Chai):
Expand Down