Skip to content

Commit

Permalink
Use session wide temp director to store plots.
Browse files Browse the repository at this point in the history
  • Loading branch information
Karan Desai committed Jun 5, 2016
1 parent 215f45c commit db2ba39
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions tardis/tests/tests_slow/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import shutil
import tempfile
import yaml
import numpy as np
Expand All @@ -18,6 +19,10 @@


def pytest_configure(config):
# A common tempdir for storing plots / PDFs and other slow test related data
# generated during execution.
tempdir_session = tempfile.mkdtemp()
config.option.tempdir = tempdir_session
html_file = tempfile.NamedTemporaryFile(delete=False)
# Html test report will be generated at this filepath by pytest-html plugin
config.option.htmlpath = html_file.name
Expand Down Expand Up @@ -58,6 +63,8 @@ def pytest_unconfigure(config):
# is not desired, hence deleted.
os.unlink(config.option.htmlpath)
print "Deleted temporary file containing html report."
# Remove tempdir by recursive deletion
shutil.rmtree(config.option.tempdir)


@pytest.fixture(scope="session")
Expand All @@ -84,19 +91,6 @@ def data_path():
return os.path.join(os.path.dirname(os.path.realpath(__file__)), "w7")


@pytest.fixture(scope="session")
def base_plot_dir():
githash_short = tardis.__githash__[0:7]
base_plot_dir = os.path.join("/tmp", "plots", githash_short)

# Remove plots generated from previous runs on same githash.
if os.path.exists(base_plot_dir):
os.rmdir(base_plot_dir)

os.makedirs(base_plot_dir)
return base_plot_dir


@pytest.fixture(scope="session")
def reference(request, reference_datadir):
"""
Expand Down

0 comments on commit db2ba39

Please sign in to comment.