Skip to content

Commit 3709e38

Browse files
committed
add tests for __repr__() functions
1 parent 4cc487a commit 3709e38

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

pvlib/test/test_location.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,3 +160,10 @@ def test_get_airmass_valueerror():
160160
end='20160101T1800-0700',
161161
freq='3H')
162162
clearsky = tus.get_airmass(times, model='invalid_model')
163+
164+
def test_Location___repr__():
165+
tus = Location(32.2, -111, 'US/Arizona', 700, 'Tucson')
166+
assert tus.__repr__()==('Tucson: latitude=32.2, longitude=-111, '+
167+
'tz=US/Arizona, altitude=700')
168+
169+

pvlib/test/test_modelchain.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,3 +198,18 @@ def test_basic_chain_altitude_pressure():
198198
expected = pd.Series(np.array([ 1.15771428788e+02, -2.00000000e-02]),
199199
index=times)
200200
assert_series_equal(ac, expected)
201+
202+
203+
def test_ModelChain___repr__():
204+
system = PVSystem()
205+
location = Location(32.2, -111, altitude=700)
206+
strategy = 'south_at_latitude_tilt'
207+
208+
mc = ModelChain(system, location, orientation_strategy=strategy)
209+
210+
# the || accounts for the coercion of 'None' to None
211+
assert mc.__repr__() == ('ModelChain for: PVSystem with tilt:32.2 and '+
212+
'azimuth: 180 with Module: None and Inverter: None with '+
213+
'orientation_startegy: south_at_latitude_tilt clearsky_model:ineichen '+
214+
'transposition_model: haydavies solar_position_method: nrel_numpy '+
215+
'airmass_model: kastenyoung1989')

pvlib/test/test_pvsystem.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,21 @@ def test_PVSystem_localize_with_latlon():
455455
assert localized_system.longitude == -111
456456

457457

458+
def test_PVSystem___repr__():
459+
system = pvsystem.PVSystem(module='blah', inverter='blarg')
460+
461+
assert system.__repr__()==('PVSystem with tilt:0 and azimuth:'+
462+
' 180 with Module: blah and Inverter: blarg')
463+
464+
465+
def test_PVSystem_localize___repr__():
466+
system = pvsystem.PVSystem(module='blah', inverter='blarg')
467+
localized_system = system.localize(latitude=32, longitude=-111)
468+
469+
assert localized_system.__repr__()==('LocalizedPVSystem with tilt:0 and'+
470+
' azimuth: 180 with Module: blah and Inverter: blarg and Location: None:'+
471+
' latitude=32, longitude=-111, tz=UTC, altitude=0')
472+
458473
# we could retest each of the models tested above
459474
# when they are attached to LocalizedPVSystem, but
460475
# that's probably not necessary at this point.
@@ -470,3 +485,13 @@ def test_LocalizedPVSystem_creation():
470485
assert localized_system.inverter == 'blarg'
471486
assert localized_system.latitude == 32
472487
assert localized_system.longitude == -111
488+
489+
490+
def test_LocalizedPVSystem___repr__():
491+
localized_system = pvsystem.LocalizedPVSystem(latitude=32,
492+
longitude=-111,
493+
module='blah',
494+
inverter='blarg')
495+
496+
assert localized_system.__repr__()==('LocalizedPVSystem with tilt:0 and'+
497+
' azimuth: 180 with Module: blah and Inverter: blarg and Location: None')

0 commit comments

Comments
 (0)