Skip to content

Commit

Permalink
ran black
Browse files Browse the repository at this point in the history
  • Loading branch information
Santosh Philip committed Nov 5, 2023
1 parent dcc4e8d commit 4e40479
Show file tree
Hide file tree
Showing 22 changed files with 78 additions and 53 deletions.
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 6 additions & 4 deletions eppy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))
Expand Down
13 changes: 7 additions & 6 deletions eppy/modeleditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,11 @@ class IDDAlreadySetError(Exception):
"""Exception Object"""

pass



class IDDResetError(Exception):
"""Exception Object"""

pass


Expand Down Expand Up @@ -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
Expand All @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions eppy/pytest_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 3 additions & 6 deletions eppy/runner/run_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion tests/pytest_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

9 changes: 5 additions & 4 deletions tests/test_IDF.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -44,8 +47,6 @@ def test_IDF():
IDF.iddname = stored_idd




class TestIDF(object):

"""py.test for IDF function"""
Expand Down
6 changes: 4 additions & 2 deletions tests/test_bunch_subclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 4 additions & 2 deletions tests/test_bunch_subclass_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions tests/test_easyopen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand Down
13 changes: 9 additions & 4 deletions tests/test_eppy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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
Expand All @@ -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
Expand Down
5 changes: 3 additions & 2 deletions tests/test_extend_extensible.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions tests/test_fanpower.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 5 additions & 2 deletions tests/test_function_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 3 additions & 2 deletions tests/test_hvacbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 4 additions & 2 deletions tests/test_idf_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions tests/test_json_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions tests/test_modeleditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand Down
Loading

0 comments on commit 4e40479

Please sign in to comment.