Skip to content

Commit

Permalink
Add plot_shell_temperature in TestW7 class.
Browse files Browse the repository at this point in the history
  • Loading branch information
Karan Desai committed Jun 17, 2016
1 parent d4576a0 commit 2b497a1
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 8 deletions.
5 changes: 2 additions & 3 deletions tardis/tests/tests_slow/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,8 @@ def pytest_runtest_makereport(item, call):
report = outcome.get_result()

if report.when == "call":
plot_obj = getattr(item, "plot_obj", None)
if plot_obj is not None:
report.extra = plot_obj.get_extras()
if "plot_object" in item.fixturenames:
report.extra = item.funcargs["plot_object"].get_extras()


@pytest.fixture(scope="function")
Expand Down
1 change: 0 additions & 1 deletion tardis/tests/tests_slow/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ def pytest_terminal_summary(self, terminalreporter):
self.dokuwiki_url, tardis.__githash__[0:7]
)
)

else:
terminalreporter.write_sep(
"-", "Connection not established, upload failed.")
37 changes: 33 additions & 4 deletions tardis/tests/tests_slow/test_w7.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,12 @@ def test_spectrum(self, plot_object):
assert_quantity_allclose(
self.reference['luminosity_density_lambda'],
self.result.runner.spectrum.luminosity_density_lambda)

plot = self.plot_spectrum(has_passed=True)
except Exception as e:
plot = self.plot_spectrum(has_passed=False)
raise e
else:
plot = self.plot_spectrum(has_passed=True)

plot_object.add(plot, "spectrum")

def plot_spectrum(self, has_passed):
Expand Down Expand Up @@ -176,7 +177,35 @@ def test_montecarlo_properties(self):
self.reference['montecarlo_nu'],
self.result.montecarlo_nu)

def test_shell_temperature(self):
assert_quantity_allclose(
def test_shell_temperature(self, plot_object):
try:
assert_quantity_allclose(
self.reference['t_rads'],
self.result.t_rads)
except Exception as e:
plot = self.plot_t_rads(has_passed=False)
raise e
else:
plot = self.plot_t_rads(has_passed=True)

plot_object.add(plot, "t_rads")

def plot_t_rads(self, has_passed):
plt.suptitle("Shell temperature for packets", fontweight="bold")
figure = plt.figure()

ax = figure.add_subplot(111)
ax.set_xlabel("Shell id")
ax.set_ylabel("t_rads")

if has_passed:
ax.text(0.8, 0.8, 'passed', transform=ax.transAxes,
bbox={'facecolor': 'green', 'alpha': 0.5, 'pad': 10})
ax.plot(self.result.t_rads, color="green", marker=".")
else:
ax.text(0.8, 0.8, 'failed', transform=ax.transAxes,
bbox={'facecolor': 'red', 'alpha': 0.5, 'pad': 10})
ax.plot(self.result.t_rads, color="red", marker=".")
ax.axis([0, 28, 5000, 10000])

return figure

0 comments on commit 2b497a1

Please sign in to comment.