From bcc81201884f3696f926d4967e336739f803d334 Mon Sep 17 00:00:00 2001 From: cdeline Date: Mon, 7 Oct 2024 10:15:15 -0600 Subject: [PATCH] fixes #256 - not useful error when trying to load a module not in .json file --- bifacial_radiance/module.py | 2 +- tests/test_bifacial_radiance.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/bifacial_radiance/module.py b/bifacial_radiance/module.py index 18549a64..cbf7757a 100644 --- a/bifacial_radiance/module.py +++ b/bifacial_radiance/module.py @@ -272,7 +272,7 @@ def readModule(self, name=None): return moduleDict else: - print('Error: module name {} doesnt exist'.format(name)) + raise Exception('Error: module name "{}" doesnt exist'.format(name)) return {} diff --git a/tests/test_bifacial_radiance.py b/tests/test_bifacial_radiance.py index cfa6e60f..99fa585f 100644 --- a/tests/test_bifacial_radiance.py +++ b/tests/test_bifacial_radiance.py @@ -604,5 +604,19 @@ def test_raypath(): assert '.' in re.split(':|;', os.environ['RAYPATH']) os.environ['RAYPATH'] = raypath0 + +def test_GH256_nomodule_error(): + moduletype = 'moduletypeNOTonJason' + startdate= '09_23_08' + enddate = '09_23_08' + demo = bifacial_radiance.RadianceObj('test') + metdata = demo.readWeatherFile(MET_FILENAME, starttime=startdate, endtime=enddate) + demo.setGround() + sceneDict = {'pitch': 7,'hub_height':2, 'nMods':1, 'nRows': 1, 'module_type':moduletype} + trackerdict = demo.set1axis(metdata = metdata, cumulativesky = False) + foodict = demo.gendaylit1axis() + with pytest.raises(Exception): + foodict = demo.makeScene1axis(trackerdict=foodict, module=moduletype, + sceneDict=sceneDict, cumulativesky=False) \ No newline at end of file