emkornfield commented on a change in pull request #7816:
URL: https://github.com/apache/arrow/pull/7816#discussion_r463916946



##########
File path: python/pyarrow/tests/test_types.py
##########
@@ -251,6 +254,121 @@ def test_is_primitive():
     assert not types.is_primitive(pa.list_(pa.int32()))
 
 
+@pytest.mark.parametrize(('tz', 'expected'), [
+    (pytz.utc, 'UTC'),
+    (pytz.timezone('Europe/Paris'), 'Europe/Paris'),
+    (pytz.FixedOffset(180), '+03:00'),
+    (datetime.timezone.utc, '+00:00'),
+    (datetime.timezone(datetime.timedelta(hours=1, minutes=30)), '+01:30')
+])
+def test_tzinfo_to_string(tz, expected):
+    assert pa.lib.tzinfo_to_string(tz) == expected
+
+
+@pytest.mark.skipif(sys.version_info <= (3, 7), reason=(
+    "Since python 3.7 the UTC offset for datetime.timezone is not restricted "
+    "to a whole number of minutes"
+))
+def test_tzinfo_to_string_errors():
+    msg = "Offset must represent whole number of minutes"
+    with pytest.raises(ValueError, match=msg):
+        tz = datetime.timezone(datetime.timedelta(hours=1, seconds=30))
+        pa.lib.tzinfo_to_string(tz)
+
+    msg = "Not an instance of datetime.tzinfo"
+    with pytest.raises(ValueError):
+        pa.lib.tzinfo_to_string("Europe/Budapest")
+
+
+def test_convert_custom_tzinfo_objects_to_string():

Review comment:
       thank you for the thorough tests.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to