From 4e404797429d5289d47b37c991c37f91308ee9cf Mon Sep 17 00:00:00 2001 From: Santosh Philip Date: Sun, 5 Nov 2023 09:40:08 -0800 Subject: [PATCH] ran black --- docs/conf.py | 2 +- eppy/__init__.py | 10 ++++++---- eppy/modeleditor.py | 13 +++++++------ eppy/pytest_helpers.py | 4 ++-- eppy/runner/run_functions.py | 9 +++------ tests/pytest_helpers.py | 2 +- tests/test_IDF.py | 9 +++++---- tests/test_bunch_subclass.py | 6 ++++-- tests/test_bunch_subclass_functions.py | 6 ++++-- tests/test_easyopen.py | 2 ++ tests/test_eppy.py | 13 +++++++++---- tests/test_extend_extensible.py | 5 +++-- tests/test_fanpower.py | 5 +++-- tests/test_function_helpers.py | 7 +++++-- tests/test_hvacbuilder.py | 5 +++-- tests/test_idf_helpers.py | 6 ++++-- tests/test_json_functions.py | 5 +++-- tests/test_modeleditor.py | 6 +++--- tests/test_parse_error.py | 2 +- tests/test_runner.py | 4 ++-- tests/test_simpleread.py | 4 +++- tests/test_thermal_properties.py | 6 ++++-- 22 files changed, 78 insertions(+), 53 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index b7933ab3..50026457 100755 --- a/docs/conf.py +++ b/docs/conf.py @@ -71,7 +71,7 @@ # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. -language = 'en' +language = "en" # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. diff --git a/eppy/__init__.py b/eppy/__init__.py index 5620645e..9a8906e1 100644 --- a/eppy/__init__.py +++ b/eppy/__init__.py @@ -20,17 +20,18 @@ from io import StringIO import eppy -from eppy import modeleditor +from eppy import modeleditor from eppy.modeleditor import IDF + def newidf(version=None): """open a new idf file easy way to open a new idf file for particular version. Works only if Energyplus of that version is installed. - + - newidf(version=None) or newidf() will workif the IDD has already been set - newidf(version=some_version) will work - - if some_version matches the IDD already set + - if some_version matches the IDD already set - OR if no IDD has been set Parameters @@ -44,10 +45,11 @@ def newidf(version=None): file of type eppy.modelmake.IDF """ # noqa: E501 import eppy.easyopen as easyopen + if not version: return IDF(StringIO("")) # return easyopen.easyopen(StringIO("")) - + import eppy.easyopen as easyopen idfstring = " Version,{};".format(str(version)) diff --git a/eppy/modeleditor.py b/eppy/modeleditor.py index 523213e2..38604509 100644 --- a/eppy/modeleditor.py +++ b/eppy/modeleditor.py @@ -59,9 +59,11 @@ class IDDAlreadySetError(Exception): """Exception Object""" pass - + + class IDDResetError(Exception): """Exception Object""" + pass @@ -617,17 +619,17 @@ def setiddname(cls, iddname, testing=False): if testing == False: errortxt = "IDD file is set to: %s" % (cls.iddname,) raise IDDAlreadySetError(errortxt) - + @classmethod def resetidd(cls): """resets the IDD for testing. Users should not use this - + It will raise the exception IDDResetError - + Returns ------- None - + """ cls.iddname = None cls.idd_info = None @@ -636,7 +638,6 @@ def resetidd(cls): cls.idd_index = None cls.idd_version = None raise IDDResetError("IDD should never be reset unless you are doing test runs") - @classmethod def getiddname(cls): diff --git a/eppy/pytest_helpers.py b/eppy/pytest_helpers.py index 4e8aae5b..03d9d64a 100755 --- a/eppy/pytest_helpers.py +++ b/eppy/pytest_helpers.py @@ -33,10 +33,10 @@ def do_integration_tests(): """ try: - result = os.environ['EPPY_INTEGRATION'] + result = os.environ["EPPY_INTEGRATION"] except KeyError as e: result = False - if result == "TRUE": # github CI returns strings 9no booleans) + if result == "TRUE": # github CI returns strings 9no booleans) result = True return result diff --git a/eppy/runner/run_functions.py b/eppy/runner/run_functions.py index 64e292bb..d94e7b8e 100644 --- a/eppy/runner/run_functions.py +++ b/eppy/runner/run_functions.py @@ -353,13 +353,10 @@ def run( # this will still work with non-existent file - fix for issue #411 if not os.path.isfile(hold_weather): # from https://stackoverflow.com/questions/36077266/how-do-i-raise-a-filenotfounderror-properly - raise EnergyPlusRunError( - f"ERROR: Could not find weather file: {hold_weather}" - ) - # errno.ENOENT, os.strerror(errno.ENOENT), hold_weather) + raise EnergyPlusRunError(f"ERROR: Could not find weather file: {hold_weather}") + # errno.ENOENT, os.strerror(errno.ENOENT), hold_weather) args["weather"] = hold_weather - - + output_dir = os.path.abspath(args["output_directory"]) args["output_directory"] = output_dir if iddname is not None: diff --git a/tests/pytest_helpers.py b/tests/pytest_helpers.py index 11e79328..8dec8b43 100644 --- a/tests/pytest_helpers.py +++ b/tests/pytest_helpers.py @@ -9,10 +9,10 @@ import eppy + def safeIDDreset(): """reset the IDD for testing and catch the exception""" try: eppy.modeleditor.IDF.resetidd() except eppy.modeleditor.IDDResetError as e: pass - diff --git a/tests/test_IDF.py b/tests/test_IDF.py index 11f4d602..039db496 100644 --- a/tests/test_IDF.py +++ b/tests/test_IDF.py @@ -18,19 +18,22 @@ # Not sure why these tests are sitting in this file # Should it not be in test_modeleditor.py or test_modeleditor1.py + def setup_module(module): """ idd is read only once in this module - if it has already been read from some other module, it will continue + if it has already been read from some other module, it will continue without reading it again - + pytest run this before running the module """ from eppy.iddcurrent import iddcurrent + iddfhandle = StringIO(iddcurrent.iddtxt) if IDF.getiddname() == None: IDF.setiddname(iddfhandle) + def test_IDF(): """py.test for class IDF""" stored_idd = IDF.iddname @@ -44,8 +47,6 @@ def test_IDF(): IDF.iddname = stored_idd - - class TestIDF(object): """py.test for IDF function""" diff --git a/tests/test_bunch_subclass.py b/tests/test_bunch_subclass.py index 155c4847..033ed873 100644 --- a/tests/test_bunch_subclass.py +++ b/tests/test_bunch_subclass.py @@ -32,16 +32,18 @@ def setup_module(module): """ idd is read only once in this module - if it has already been read from some other module, it will continue + if it has already been read from some other module, it will continue without reading it again - + pytest run this before running the module """ from eppy.iddcurrent import iddcurrent + iddfhandle = StringIO(iddcurrent.iddtxt) if IDF.getiddname() == None: IDF.setiddname(iddfhandle) + # This test is ugly because I have to send file names and not able to send file handles idftxt = """Version,6.0; diff --git a/tests/test_bunch_subclass_functions.py b/tests/test_bunch_subclass_functions.py index 2b6a7cd6..e215e085 100644 --- a/tests/test_bunch_subclass_functions.py +++ b/tests/test_bunch_subclass_functions.py @@ -21,16 +21,18 @@ def setup_module(module): """ idd is read only once in this module - if it has already been read from some other module, it will continue + if it has already been read from some other module, it will continue without reading it again - + pytest run this before running the module """ from eppy.iddcurrent import iddcurrent + iddfhandle = StringIO(iddcurrent.iddtxt) if IDF.getiddname() == None: IDF.setiddname(iddfhandle) + idftxt = """Version,8.0; Building, diff --git a/tests/test_easyopen.py b/tests/test_easyopen.py index 20a57464..64f981e4 100644 --- a/tests/test_easyopen.py +++ b/tests/test_easyopen.py @@ -26,10 +26,12 @@ from tests.pytest_helpers import safeIDDreset + def teardown_module(module): """new IDD has been set in the module. Here you tear it down""" safeIDDreset() + def test_cleanupversion(): """py.test for cleanupversion""" data = ( diff --git a/tests/test_eppy.py b/tests/test_eppy.py index 76044a8f..b4c6508b 100644 --- a/tests/test_eppy.py +++ b/tests/test_eppy.py @@ -16,19 +16,22 @@ from tests.pytest_helpers import safeIDDreset try: - VERSION = os.environ['ENERGYPLUS_VERSION'] # used in CI files + VERSION = os.environ["ENERGYPLUS_VERSION"] # used in CI files except KeyError: VERSION = "8.9.0" # current default for integration tests on local system IDDVERSION = VERSION + def teardown_module(module): """new IDD has been set in the module. Here you tear it down""" safeIDDreset() - + + def versiontuple(vers): """version tuple""" return tuple([int(num) for num in vers.split(".")]) + @pytest.mark.skipif( not do_integration_tests(), reason="$EPPY_INTEGRATION env var not set" ) @@ -39,12 +42,14 @@ def test_newidf1(): idf = eppy.newidf(ver) result = idf.idfobjects["version".upper()][0] assert result.Version_Identifier == expected - + + @pytest.mark.skipif( not do_integration_tests(), reason="$EPPY_INTEGRATION env var not set" ) def test_newidf2(): import eppy + # Now test the following # # :Problem: eppy.newidf(version=None) does not work correctly @@ -64,7 +69,7 @@ def test_newidf2(): safeIDDreset() iddversion = IDDVERSION - idf1 = eppy.newidf(version=iddversion) # this will set the IDD version + idf1 = eppy.newidf(version=iddversion) # this will set the IDD version idf2 = eppy.newidf(version=None) assert idf2.idd_version == versiontuple(iddversion) # - eppy.newidf(version=wrongIDD): throw exception diff --git a/tests/test_extend_extensible.py b/tests/test_extend_extensible.py index 48e31fb4..721677b9 100644 --- a/tests/test_extend_extensible.py +++ b/tests/test_extend_extensible.py @@ -15,12 +15,13 @@ def setup_module(module): """ idd is read only once in this module - if it has already been read from some other module, it will continue + if it has already been read from some other module, it will continue without reading it again - + pytest run this before running the module """ from eppy.iddcurrent import iddcurrent + iddfhandle = StringIO(iddcurrent.iddtxt) if IDF.getiddname() == None: IDF.setiddname(iddfhandle) diff --git a/tests/test_fanpower.py b/tests/test_fanpower.py index 350431f5..563d799a 100644 --- a/tests/test_fanpower.py +++ b/tests/test_fanpower.py @@ -22,12 +22,13 @@ def setup_module(module): """ idd is read only once in this module - if it has already been read from some other module, it will continue + if it has already been read from some other module, it will continue without reading it again - + pytest run this before running the module """ from eppy.iddcurrent import iddcurrent + iddfhandle = StringIO(iddcurrent.iddtxt) if IDF.getiddname() == None: IDF.setiddname(iddfhandle) diff --git a/tests/test_function_helpers.py b/tests/test_function_helpers.py index a0e1b216..54f47dc1 100644 --- a/tests/test_function_helpers.py +++ b/tests/test_function_helpers.py @@ -20,19 +20,22 @@ from eppy.modeleditor import IDF from eppy.pytest_helpers import almostequal + def setup_module(module): """ idd is read only once in this module - if it has already been read from some other module, it will continue + if it has already been read from some other module, it will continue without reading it again - + pytest run this before running the module """ from eppy.iddcurrent import iddcurrent + iddfhandle = StringIO(iddcurrent.iddtxt) if IDF.getiddname() == None: IDF.setiddname(iddfhandle) + idftxt = """Version,8.0; Building, diff --git a/tests/test_hvacbuilder.py b/tests/test_hvacbuilder.py index bbb7e0a7..4d18bd71 100644 --- a/tests/test_hvacbuilder.py +++ b/tests/test_hvacbuilder.py @@ -21,12 +21,13 @@ def setup_module(module): """ idd is read only once in this module - if it has already been read from some other module, it will continue + if it has already been read from some other module, it will continue without reading it again - + pytest run this before running the module """ from eppy.iddcurrent import iddcurrent + iddfhandle = StringIO(iddcurrent.iddtxt) if IDF.getiddname() == None: IDF.setiddname(iddfhandle) diff --git a/tests/test_idf_helpers.py b/tests/test_idf_helpers.py index cd5f8f55..9ea1823c 100644 --- a/tests/test_idf_helpers.py +++ b/tests/test_idf_helpers.py @@ -17,15 +17,17 @@ from eppy.pytest_helpers import almostequal import eppy.idf_helpers as idf_helpers + def setup_module(module): """ idd is read only once in this module - if it has already been read from some other module, it will continue + if it has already been read from some other module, it will continue without reading it again - + pytest run this before running the module """ from eppy.iddcurrent import iddcurrent + iddfhandle = StringIO(iddcurrent.iddtxt) if IDF.getiddname() == None: IDF.setiddname(iddfhandle) diff --git a/tests/test_json_functions.py b/tests/test_json_functions.py index a9d1d96d..df69eaad 100644 --- a/tests/test_json_functions.py +++ b/tests/test_json_functions.py @@ -22,12 +22,13 @@ def setup_module(module): """ idd is read only once in this module - if it has already been read from some other module, it will continue + if it has already been read from some other module, it will continue without reading it again - + pytest run this before running the module """ from eppy.iddcurrent import iddcurrent + iddfhandle = StringIO(iddcurrent.iddtxt) if IDF.getiddname() == None: IDF.setiddname(iddfhandle) diff --git a/tests/test_modeleditor.py b/tests/test_modeleditor.py index 152de7bc..73bbe7f7 100644 --- a/tests/test_modeleditor.py +++ b/tests/test_modeleditor.py @@ -37,18 +37,18 @@ def setup_module(module): """ idd is read only once in this module - if it has already been read from some other module, it will continue + if it has already been read from some other module, it will continue without reading it again - + pytest run this before running the module """ from eppy.iddcurrent import iddcurrent + iddfhandle = StringIO(iddcurrent.iddtxt) if IDF.getiddname() == None: IDF.setiddname(iddfhandle) - def test_poptrailing(): """py.test for poptrailing""" tdata = ( diff --git a/tests/test_parse_error.py b/tests/test_parse_error.py index 1019f15a..316b1905 100644 --- a/tests/test_parse_error.py +++ b/tests/test_parse_error.py @@ -15,6 +15,7 @@ def teardown_module(module): """new IDD has been set in the module. Here you tear it down""" safeIDDreset() + def test_capture_stderr(): tmp_out = StringIO() sys.stderr = tmp_out @@ -41,4 +42,3 @@ def test_capture_real_error(test_idf): finally: shutil.rmtree(rundir) safeIDDreset() - \ No newline at end of file diff --git a/tests/test_runner.py b/tests/test_runner.py index 199e3c4d..ba315c98 100644 --- a/tests/test_runner.py +++ b/tests/test_runner.py @@ -47,7 +47,7 @@ def versiontuple(vers): IDD_FILES = os.path.join(RESOURCES_DIR, "iddfiles") IDF_FILES = os.path.join(RESOURCES_DIR, "idffiles") try: - VERSION = os.environ['ENERGYPLUS_INSTALL_VERSION'] # used in CI files + VERSION = os.environ["ENERGYPLUS_INSTALL_VERSION"] # used in CI files except KeyError: VERSION = "8-9-0" # current default for integration tests on local system TEST_IDF = "V{}/smallfile.idf".format(VERSION[:3].replace("-", "_")) @@ -62,6 +62,7 @@ def teardown_module(module): """new IDD has been set in the module. Here you tear it down""" safeIDDreset() + def has_severe_errors(results="run_outputs"): """Check for severe errors in the eplusout.end file.""" end_filename = glob("{}/*.end".format(results))[0] @@ -746,4 +747,3 @@ def test_multiprocess_run_IDF_from_generator(self): multirunfolder = os.path.join(THIS_DIR, "multi_runs") assert os.path.exists(multirunfolder) shutil.rmtree(multirunfolder, ignore_errors=True) - diff --git a/tests/test_simpleread.py b/tests/test_simpleread.py index ab85ed07..8bdbf303 100644 --- a/tests/test_simpleread.py +++ b/tests/test_simpleread.py @@ -14,10 +14,12 @@ import eppy.simpleread as simpleread from tests.pytest_helpers import safeIDDreset + def teardown_module(module): """new IDD has been set in the module. Here you tear it down""" safeIDDreset() - + + def test_idf2txt(): """py.test for idf2txt""" data = ( diff --git a/tests/test_thermal_properties.py b/tests/test_thermal_properties.py index 250ca016..1865f03a 100644 --- a/tests/test_thermal_properties.py +++ b/tests/test_thermal_properties.py @@ -25,12 +25,13 @@ def setup_module(module): """ idd is read only once in this module - if it has already been read from some other module, it will continue + if it has already been read from some other module, it will continue without reading it again - + pytest run this before running the module """ from eppy.iddcurrent import iddcurrent + iddfhandle = StringIO(iddcurrent.iddtxt) if IDF.getiddname() == None: IDF.setiddname(iddfhandle) @@ -38,6 +39,7 @@ def setup_module(module): class Data(object): """data""" + single_layer = """ Construction, TestConstruction, !- Name