From 1521f5e8244907632db64178eb12e9d4a151a150 Mon Sep 17 00:00:00 2001 From: Rinkle Jain Date: Mon, 13 Mar 2017 16:36:36 +0530 Subject: [PATCH 1/3] Merge 'generate_reference_path' and 'reference_path' in integration tests. --- docs/integration.yml | 8 +++---- tardis/tests/integration_tests/conftest.py | 21 +++++++++++-------- .../integration_tests/test_integration.py | 4 ++-- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/docs/integration.yml b/docs/integration.yml index a3b99f6bb3e..3d3ab2cef9b 100644 --- a/docs/integration.yml +++ b/docs/integration.yml @@ -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, diff --git a/tardis/tests/integration_tests/conftest.py b/tardis/tests/integration_tests/conftest.py index 980a35fa634..fdb69ada488 100644 --- a/tardis/tests/integration_tests/conftest.py +++ b/tardis/tests/integration_tests/conftest.py @@ -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] ))) @@ -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_filepath': 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. @@ -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_filepath'])): + os.makedirs(path['reference_filepath']) return path diff --git a/tardis/tests/integration_tests/test_integration.py b/tardis/tests/integration_tests/test_integration.py index 61c07516c31..16a342ca316 100644 --- a/tardis/tests/integration_tests/test_integration.py +++ b/tardis/tests/integration_tests/test_integration.py @@ -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_filepath'], "{0}.h5".format(self.name) ) if os.path.exists(ref_data_path): pytest.skip( @@ -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_filepath'] )) capmanager.resumecapture() From a4e379c90e81199d20d422509fd41db924bb41b8 Mon Sep 17 00:00:00 2001 From: Rinkle Jain Date: Mon, 13 Mar 2017 16:36:36 +0530 Subject: [PATCH 2/3] Merge 'generate_reference_path' and 'reference_path' in integration tests. --- docs/integration.yml | 8 +++---- tardis/tests/integration_tests/conftest.py | 21 +++++++++++-------- .../integration_tests/test_integration.py | 4 ++-- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/docs/integration.yml b/docs/integration.yml index a3b99f6bb3e..3d3ab2cef9b 100644 --- a/docs/integration.yml +++ b/docs/integration.yml @@ -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, diff --git a/tardis/tests/integration_tests/conftest.py b/tardis/tests/integration_tests/conftest.py index 980a35fa634..fdb69ada488 100644 --- a/tardis/tests/integration_tests/conftest.py +++ b/tardis/tests/integration_tests/conftest.py @@ -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] ))) @@ -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_filepath': 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. @@ -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_filepath'])): + os.makedirs(path['reference_filepath']) return path diff --git a/tardis/tests/integration_tests/test_integration.py b/tardis/tests/integration_tests/test_integration.py index 61c07516c31..16a342ca316 100644 --- a/tardis/tests/integration_tests/test_integration.py +++ b/tardis/tests/integration_tests/test_integration.py @@ -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_filepath'], "{0}.h5".format(self.name) ) if os.path.exists(ref_data_path): pytest.skip( @@ -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_filepath'] )) capmanager.resumecapture() From 312c33b2a6bf611291057af13235fa7f6513c588 Mon Sep 17 00:00:00 2001 From: Rinkle Jain Date: Tue, 14 Mar 2017 00:15:53 +0530 Subject: [PATCH 3/3] Made suggested changes --- tardis/tests/integration_tests/conftest.py | 12 ++++++------ tardis/tests/integration_tests/test_integration.py | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tardis/tests/integration_tests/conftest.py b/tardis/tests/integration_tests/conftest.py index fdb69ada488..f087bcce884 100644 --- a/tardis/tests/integration_tests/conftest.py +++ b/tardis/tests/integration_tests/conftest.py @@ -88,7 +88,7 @@ def data_path(request): path = { 'config_dirpath': request.param, - 'reference_filepath': ref_path, + '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. @@ -102,8 +102,8 @@ def data_path(request): )) if (request.config.getoption("--generate-reference") and not - os.path.exists(path['reference_filepath'])): - os.makedirs(path['reference_filepath']) + os.path.exists(path['reference_path'])): + os.makedirs(path['reference_path']) return path @@ -113,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 @@ -122,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 diff --git a/tardis/tests/integration_tests/test_integration.py b/tardis/tests/integration_tests/test_integration.py index 16a342ca316..3da9dbd0ee8 100644 --- a/tardis/tests/integration_tests/test_integration.py +++ b/tardis/tests/integration_tests/test_integration.py @@ -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['reference_filepath'], "{0}.h5".format(self.name) + data_path['reference_path'], "{0}.h5".format(self.name) ) if os.path.exists(ref_data_path): pytest.skip( @@ -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['reference_filepath'] + data_path['reference_path'] )) capmanager.resumecapture()