Skip to content

Commit

Permalink
windows does not like contextual temp files
Browse files Browse the repository at this point in the history
  • Loading branch information
thurber committed Jun 16, 2021
1 parent 2ccc83d commit b852427
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ diyepw/data/tmy_epw_files/*
*.egg-info

# Python cache files
venv*
__pycache__

# Files generated by unit testing
Expand Down
3 changes: 2 additions & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
xarray~=0.16.2
numpy~=1.19.2
numpy~=1.19.2
pvlib~=0.8.1
21 changes: 11 additions & 10 deletions tests/test_meteorology.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,17 @@ def test_write_epw(self):
Confirm that an EPW file generated by the Meteorology.write_epw() method is a valid EPW file
:return:
"""
with tempfile.NamedTemporaryFile('w+') as tmp_file:
self._meteorology.write_epw(tmp_file.name)
with open(tmp_file.name, "r") as m:
try:
parsed_epw, col_names = pvlib.iotools.parse_epw(m)
except Exception as e:
raise Exception(f"Encountered an error trying to parse the produce of Meteorology.write_epw() as an EPW file: {e}")

# Make sure that parse_epw() actually succeeded in creating a DataFrame instance
self.assertIsInstance(parsed_epw, pd.DataFrame)
tmp_file = os.path.join(tempfile.gettempdir(), os.urandom(24).hex())
self._meteorology.write_epw(tmp_file)
with open(tmp_file, "r") as m:
try:
parsed_epw, col_names = pvlib.iotools.parse_epw(m)
except Exception as e:
raise Exception(f"Encountered an error trying to parse the produce of Meteorology.write_epw() as an EPW file: {e}")

# Make sure that parse_epw() actually succeeded in creating a DataFrame instance
self.assertIsInstance(parsed_epw, pd.DataFrame)
os.unlink(tmp_file)


def test_property_setters_and_getters__good_values(self):
Expand Down

0 comments on commit b852427

Please sign in to comment.