Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge 'generate_reference_path' and 'reference_path' in integration tests (bug #672) #715

Merged
merged 4 commits into from
Apr 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions docs/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@ report:
reportpath: "~/projects/tardis/integration"


# Path to directory containing reference HDF files.
reference: "~/projects/tardis/integration/"

# Path to directory where reference HDF files will be generated and
# saved during the test run. Use "--generate-reference" flag in command
# line args for the purpose, for other cases this will be simply ignored.
generate_reference: "~/projects/tardis/integration/"
# line args for the purpose, for other cases this will denote path
# to the directory containing reference HDF files.
reference: "~/projects/tardis/integration/"


# Speeds up test execution by reducing amount of packets per iteration,
Expand Down
27 changes: 15 additions & 12 deletions tardis/tests/integration_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def pytest_terminal_summary(terminalreporter):
terminalreporter.config.getvalue("integration-tests")):
# TODO: Add a check whether generation was successful or not.
terminalreporter.write_sep("-", "Generated reference data: {0}".format(os.path.join(
terminalreporter.config.integration_tests_config['generate_reference'],
terminalreporter.config.integration_tests_config['reference'],
tardis_githash[:7]
)))

Expand Down Expand Up @@ -77,15 +77,18 @@ def plot_object(request):
def data_path(request):
integration_tests_config = request.config.integration_tests_config
hdf_filename = "{0}.h5".format(os.path.basename(request.param))
if (request.config.getoption("--generate-reference") ):
ref_path = os.path.join(os.path.expandvars(os.path.expanduser(
integration_tests_config['reference'])), tardis_githash[:7]
)
else:
ref_path = os.path.join(os.path.expandvars(
os.path.expanduser(integration_tests_config['reference'])), hdf_filename
)

path = {
'config_dirpath': request.param,
'reference_filepath': os.path.join(os.path.expandvars(
os.path.expanduser(integration_tests_config['reference'])), hdf_filename
),
'gen_ref_path': os.path.join(os.path.expandvars(os.path.expanduser(
integration_tests_config['generate_reference'])), tardis_githash[:7]
),
'reference_path': ref_path,
'setup_name': hdf_filename[:-3],
# Temporary hack for providing atom data per individual setup.
# This url has all the atom data files hosted, for downloading.
Expand All @@ -99,8 +102,8 @@ def data_path(request):
))

if (request.config.getoption("--generate-reference") and not
os.path.exists(path['gen_ref_path'])):
os.makedirs(path['gen_ref_path'])
os.path.exists(path['reference_path'])):
os.makedirs(path['reference_path'])
return path


Expand All @@ -110,7 +113,7 @@ def reference(request, data_path):
HDF file. All data is unpacked as a collection of ``pd.Series`` and
``pd.DataFrames`` in a ``pd.HDFStore`` object and returned away.

Assumed that ``data_path['reference_filepath']`` is a valid HDF file
Assumed that ``data_path['reference_path']`` is a valid HDF file
containing the reference dath for a particular setup.
"""
# Reference data need not be loaded and provided if current test run itself
Expand All @@ -119,10 +122,10 @@ def reference(request, data_path):
return
else:
try:
reference = pd.HDFStore(data_path['reference_filepath'], 'r')
reference = pd.HDFStore(data_path['reference_path'], 'r')
except IOError:
raise IOError('Reference file {0} does not exist and is needed'
' for the tests'.format(data_path['reference_filepath']))
' for the tests'.format(data_path['reference_path']))

else:
return reference
4 changes: 2 additions & 2 deletions tardis/tests/integration_tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def setup(self, request, reference, data_path, pytestconfig):
self.result.run()
if request.config.getoption("--generate-reference"):
ref_data_path = os.path.join(
data_path['gen_ref_path'], "{0}.h5".format(self.name)
data_path['reference_path'], "{0}.h5".format(self.name)
)
if os.path.exists(ref_data_path):
pytest.skip(
Expand All @@ -138,7 +138,7 @@ def setup(self, request, reference, data_path, pytestconfig):
self.result.to_hdf(path_or_buf=ref_data_path,
suffix_count=False)
pytest.skip("Reference data saved at {0}".format(
data_path['gen_ref_path']
data_path['reference_path']
))
capmanager.resumecapture()

Expand Down