forked from santoshphilip/eppy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test for an error that is still raised
This is needed since we now automatically expand objects if required.
- Loading branch information
jamiebull1
authored and
jamiebull1
committed
Sep 14, 2019
1 parent
122853d
commit 85a0271
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
|
||
import os | ||
import shutil | ||
import sys | ||
|
||
from six import StringIO | ||
|
||
from eppy.runner.run_functions import parse_error, EnergyPlusRunError | ||
|
||
|
||
def test_capture_stderr(): | ||
tmp_out = StringIO() | ||
sys.stderr = tmp_out | ||
sys.stderr.write("I am in stderr") | ||
msg = parse_error(tmp_out, "C:/notafile") | ||
assert "<File not found>" in msg | ||
assert "I am in stderr" in msg | ||
sys.stderr = sys.__stderr__ | ||
|
||
|
||
def test_capture_real_error(test_idf): | ||
test_idf.newidfobject( | ||
"HVACTemplate:Thermostat", | ||
Name="thermostat VRF", | ||
Heating_Setpoint_Schedule_Name=15, | ||
Constant_Cooling_Setpoint=25, | ||
) | ||
rundir = "test_capture_real_error" | ||
os.mkdir(rundir) | ||
try: | ||
test_idf.run(output_directory=rundir) | ||
except EnergyPlusRunError as e: | ||
assert "invalid Heating Setpoint Temperature Schedule" in str(e) | ||
finally: | ||
shutil.rmtree(rundir) |