Skip to content

Commit 60a5d94

Browse files
Add timezone type checks to Location init test
1 parent 01263c2 commit 60a5d94

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

pvlib/location.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ def __init__(self, latitude, longitude, tz='UTC', altitude=None,
7272
self.tz = 'UTC'
7373
self.pytz = pytz.UTC
7474
elif isinstance(tz, datetime.tzinfo):
75+
# This includes pytz timezones.
7576
self.tz = tz.zone
7677
self.pytz = pytz.timezone(tz.zone)
7778
elif isinstance(tz, (int, float)):

pvlib/tests/test_location.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,16 @@ def test_location_all():
2828

2929

3030
@pytest.mark.parametrize('tz', [
31-
pytz.timezone('US/Arizona'), 'America/Phoenix', -7, -7.0,
32-
datetime.timezone.utc
31+
'America/Phoenix',
32+
datetime.timezone.utc,
33+
pytz.timezone('US/Arizona'),
34+
-7,
35+
-7.0,
3336
])
3437
def test_location_tz(tz):
35-
Location(32.2, -111, tz)
38+
loc = Location(32.2, -111, tz)
39+
assert type(loc.tz) is str
40+
assert isinstance(loc.pytz, pytz.tzinfo.BaseTzInfo)
3641

3742

3843
def test_location_invalid_tz():

0 commit comments

Comments
 (0)