diff --git a/tardis/tests/tests_slow/conftest.py b/tardis/tests/tests_slow/conftest.py index 6990cc84b7d..d6b0fa5ad33 100644 --- a/tardis/tests/tests_slow/conftest.py +++ b/tardis/tests/tests_slow/conftest.py @@ -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") diff --git a/tardis/tests/tests_slow/report.py b/tardis/tests/tests_slow/report.py index b0bd283222e..ffab6e29cd6 100644 --- a/tardis/tests/tests_slow/report.py +++ b/tardis/tests/tests_slow/report.py @@ -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.") diff --git a/tardis/tests/tests_slow/test_w7.py b/tardis/tests/tests_slow/test_w7.py index cd418158daa..e3ecb8a0269 100644 --- a/tardis/tests/tests_slow/test_w7.py +++ b/tardis/tests/tests_slow/test_w7.py @@ -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): @@ -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