From b12b9f0cb5660c8784c06fca57e5c233e40d280a Mon Sep 17 00:00:00 2001 From: Charles-Axel Dein Date: Wed, 7 Aug 2019 16:10:38 +0200 Subject: [PATCH] Fix locale argument to get --- arrow/factory.py | 2 +- tests/factory_tests.py | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/arrow/factory.py b/arrow/factory.py index c4c7291d8..8cca6ac9b 100644 --- a/arrow/factory.py +++ b/arrow/factory.py @@ -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 diff --git a/tests/factory_tests.py b/tests/factory_tests.py index 635f0d0d4..acd4c36a0 100644 --- a/tests/factory_tests.py +++ b/tests/factory_tests.py @@ -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):