diff --git a/pyepw/epw.py b/pyepw/epw.py index 99258f6..fe2b6b0 100644 --- a/pyepw/epw.py +++ b/pyepw/epw.py @@ -7417,15 +7417,14 @@ def _create_datadict(cls, internal_name): raise ValueError( "No DataDictionary known for {}".format(internal_name)) - def read(self, path): - """Read EPW weather data from path. + def read_string_io(self, string_io): + """Read EPW weather data from StringIO object. Args: - path (str): path to read weather data from + string_io (StringIO): stringio to read weather data from """ - with open(path, "r") as f: - for line in f: + for line in string_io: line = line.strip() match_obj_name = re.search(r"^([A-Z][A-Z/ \d]+),", line) if match_obj_name is not None: @@ -7440,3 +7439,15 @@ def read(self, path): wd = WeatherData() wd.read(line.strip().split(',')) self.add_weatherdata(wd) + + + def read(self, path): + """Read EPW weather data from file at path. + + Args: + path (str): path to read weather data from + + """ + with open(path, "r") as f: + self.read_string_io(f) + diff --git a/tests/__init__.py b/test/__init__.py similarity index 100% rename from tests/__init__.py rename to test/__init__.py diff --git a/tests/data/USA_CA_San.Francisco.Intl.AP.724940_TMY3.epw b/test/data/USA_CA_San.Francisco.Intl.AP.724940_TMY3.epw similarity index 100% rename from tests/data/USA_CA_San.Francisco.Intl.AP.724940_TMY3.epw rename to test/data/USA_CA_San.Francisco.Intl.AP.724940_TMY3.epw diff --git a/tests/test_comments_1.py b/test/test_comments_1.py similarity index 100% rename from tests/test_comments_1.py rename to test/test_comments_1.py diff --git a/tests/test_comments_2.py b/test/test_comments_2.py similarity index 100% rename from tests/test_comments_2.py rename to test/test_comments_2.py diff --git a/tests/test_data_periods.py b/test/test_data_periods.py similarity index 100% rename from tests/test_data_periods.py rename to test/test_data_periods.py diff --git a/tests/test_design_conditions.py b/test/test_design_conditions.py similarity index 100% rename from tests/test_design_conditions.py rename to test/test_design_conditions.py diff --git a/tests/test_ground_temperatures.py b/test/test_ground_temperatures.py similarity index 100% rename from tests/test_ground_temperatures.py rename to test/test_ground_temperatures.py diff --git a/tests/test_holidays_or_daylight_savings.py b/test/test_holidays_or_daylight_savings.py similarity index 100% rename from tests/test_holidays_or_daylight_savings.py rename to test/test_holidays_or_daylight_savings.py diff --git a/tests/test_location.py b/test/test_location.py similarity index 100% rename from tests/test_location.py rename to test/test_location.py diff --git a/tests/test_read.py b/test/test_read.py similarity index 82% rename from tests/test_read.py rename to test/test_read.py index e1719d1..7e3a744 100644 --- a/tests/test_read.py +++ b/test/test_read.py @@ -15,7 +15,7 @@ def tearDown(self): def test_read_epw(self): epw = EPW() - epw.read(r"tests/data/USA_CA_San.Francisco.Intl.AP.724940_TMY3.epw") + epw.read(r"test/data/USA_CA_San.Francisco.Intl.AP.724940_TMY3.epw") epw.save(self.path) epw2 = EPW() diff --git a/tests/test_typical_or_extreme_periods.py b/test/test_typical_or_extreme_periods.py similarity index 100% rename from tests/test_typical_or_extreme_periods.py rename to test/test_typical_or_extreme_periods.py