From 9deb404038a65edcb4e5af2e22bdcf47f68f60ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ezequiel=20P=C3=A1ssaro?= Date: Thu, 11 Jun 2020 11:49:56 -0300 Subject: [PATCH 1/7] Unpin pytest version from environment file --- azure-pipelines/simple_test_framework.yml | 2 +- tardis_env3.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/azure-pipelines/simple_test_framework.yml b/azure-pipelines/simple_test_framework.yml index c345cb4c208..ea5fc6d6717 100644 --- a/azure-pipelines/simple_test_framework.yml +++ b/azure-pipelines/simple_test_framework.yml @@ -56,7 +56,7 @@ jobs: - bash: | source activate tardis conda install -y pytest-cov - pip install git+https://github.com/tonybaloney/pytest-azurepipelines.git + pip install pytest-azurepipelines pytest tardis --tardis-refdata=$(ref.data.home) --cov=tardis --cov-report=xml --cov-report=html displayName: "TARDIS test" diff --git a/tardis_env3.yml b/tardis_env3.yml index 8f0539b7893..ab07383b4fd 100644 --- a/tardis_env3.yml +++ b/tardis_env3.yml @@ -52,7 +52,7 @@ dependencies: #Test/Coverage requirements - git-lfs - - pytest=4 + - pytest - pytest-html - requests - coverage From bb170bfbe52475ed0d0f8b179d013e4ff1398b25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ezequiel=20P=C3=A1ssaro?= Date: Thu, 11 Jun 2020 12:33:00 -0300 Subject: [PATCH 2/7] Fix integration tests skip condition --- tardis/conftest.py | 5 +++++ tardis/tests/integration_tests/test_integration.py | 4 +--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tardis/conftest.py b/tardis/conftest.py index 3028372a815..22c41be13a3 100644 --- a/tardis/conftest.py +++ b/tardis/conftest.py @@ -155,6 +155,11 @@ def tardis_ref_path(): else: return os.path.expandvars(os.path.expanduser(tardis_ref_path)) +@pytest.fixture(scope='session') +def integration_tests(): + if not pytest.config.getvalue('integration-tests'): + pytest.skip('integration tests are not included in this run') + from tardis.tests.fixtures.atom_data import * @pytest.yield_fixture(scope="session") diff --git a/tardis/tests/integration_tests/test_integration.py b/tardis/tests/integration_tests/test_integration.py index 82c1d0407bc..272b1188a37 100644 --- a/tardis/tests/integration_tests/test_integration.py +++ b/tardis/tests/integration_tests/test_integration.py @@ -58,8 +58,6 @@ def model_quantities(request): return request.param -@pytest.mark.skipif(not pytest.config.getvalue("integration-tests"), - reason="integration tests are not included in this run") @pytest.mark.integration class TestIntegration(object): """Slow integration test for various setups present in subdirectories of @@ -68,7 +66,7 @@ class TestIntegration(object): @classmethod @pytest.fixture(scope="class", autouse=True) - def setup(self, request, reference, data_path, pytestconfig): + def setup(self, request, reference, data_path, pytestconfig, integration_tests): """ This method does initial setup of creating configuration and performing a single run of integration test. From 6c37c891db88be56566e0b5fa111c89e17c2e50b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ezequiel=20P=C3=A1ssaro?= Date: Thu, 11 Jun 2020 13:09:37 -0300 Subject: [PATCH 3/7] Revert "Fix integration tests skip condition" This reverts commit bb170bfbe52475ed0d0f8b179d013e4ff1398b25. --- tardis/conftest.py | 5 ----- tardis/tests/integration_tests/test_integration.py | 4 +++- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/tardis/conftest.py b/tardis/conftest.py index 22c41be13a3..3028372a815 100644 --- a/tardis/conftest.py +++ b/tardis/conftest.py @@ -155,11 +155,6 @@ def tardis_ref_path(): else: return os.path.expandvars(os.path.expanduser(tardis_ref_path)) -@pytest.fixture(scope='session') -def integration_tests(): - if not pytest.config.getvalue('integration-tests'): - pytest.skip('integration tests are not included in this run') - from tardis.tests.fixtures.atom_data import * @pytest.yield_fixture(scope="session") diff --git a/tardis/tests/integration_tests/test_integration.py b/tardis/tests/integration_tests/test_integration.py index 272b1188a37..82c1d0407bc 100644 --- a/tardis/tests/integration_tests/test_integration.py +++ b/tardis/tests/integration_tests/test_integration.py @@ -58,6 +58,8 @@ def model_quantities(request): return request.param +@pytest.mark.skipif(not pytest.config.getvalue("integration-tests"), + reason="integration tests are not included in this run") @pytest.mark.integration class TestIntegration(object): """Slow integration test for various setups present in subdirectories of @@ -66,7 +68,7 @@ class TestIntegration(object): @classmethod @pytest.fixture(scope="class", autouse=True) - def setup(self, request, reference, data_path, pytestconfig, integration_tests): + def setup(self, request, reference, data_path, pytestconfig): """ This method does initial setup of creating configuration and performing a single run of integration test. From b7838c3dec4793a571472dc8640e5da7965fd561 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ezequiel=20P=C3=A1ssaro?= Date: Thu, 11 Jun 2020 13:18:25 -0300 Subject: [PATCH 4/7] Trying new solution --- tardis/tests/integration_tests/test_integration.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tardis/tests/integration_tests/test_integration.py b/tardis/tests/integration_tests/test_integration.py index 82c1d0407bc..f20c9a1052e 100644 --- a/tardis/tests/integration_tests/test_integration.py +++ b/tardis/tests/integration_tests/test_integration.py @@ -58,7 +58,7 @@ def model_quantities(request): return request.param -@pytest.mark.skipif(not pytest.config.getvalue("integration-tests"), +@pytest.mark.skipif('not config.getvalue("integration-tests")', reason="integration tests are not included in this run") @pytest.mark.integration class TestIntegration(object): From 6e4618904a893f8d7da3383f1a1c391d45eebb2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ezequiel=20P=C3=A1ssaro?= Date: Thu, 11 Jun 2020 13:58:19 -0300 Subject: [PATCH 5/7] Using `pytestconfig` --- tardis/conftest.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tardis/conftest.py b/tardis/conftest.py index 3028372a815..faae42e5caf 100644 --- a/tardis/conftest.py +++ b/tardis/conftest.py @@ -139,8 +139,8 @@ def pytest_addoption(parser): @pytest.fixture(scope='session') -def generate_reference(): - option = pytest.config.getvalue("generate_reference") +def generate_reference(pytestconfig): + option = pytestconfig.getvalue("generate_reference") if option is None: return False else: @@ -148,8 +148,8 @@ def generate_reference(): @pytest.fixture(scope="session") -def tardis_ref_path(): - tardis_ref_path = pytest.config.getvalue("tardis_refdata") +def tardis_ref_path(pytestconfig): + tardis_ref_path = pytestconfig.getvalue("tardis_refdata") if tardis_ref_path is None: pytest.skip('--tardis-refdata was not specified') else: From a1419bf7af7ad1d74be739d3e1836846128195c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ezequiel=20P=C3=A1ssaro?= Date: Thu, 11 Jun 2020 14:05:24 -0300 Subject: [PATCH 6/7] Using `pytestconfig` (2) --- tardis/montecarlo/tests/test_packet_source.py | 4 ++-- tardis/plasma/tests/test_complete_plasmas.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tardis/montecarlo/tests/test_packet_source.py b/tardis/montecarlo/tests/test_packet_source.py index 1bacfc50872..daaad32210f 100644 --- a/tardis/montecarlo/tests/test_packet_source.py +++ b/tardis/montecarlo/tests/test_packet_source.py @@ -17,10 +17,10 @@ def packet_unit_test_fpath(tardis_ref_path): return os.path.abspath(os.path.join( tardis_ref_path, 'packet_unittest.h5')) -def test_bb_packet_sampling(tardis_ref_data, packet_unit_test_fpath): +def test_bb_packet_sampling(pytestconfig, tardis_ref_data, packet_unit_test_fpath): bb = BlackBodySimpleSource(2508) #ref_df = pd.read_hdf('test_bb_sampling.h5') - if pytest.config.getvalue("--generate-reference"): + if pytestconfig.getvalue("--generate-reference"): ref_bb = pd.read_hdf(packet_unit_test_fpath, key='/blackbody') ref_bb.to_hdf(tardis_ref_data, key='/packet_unittest/blackbody', mode='a') diff --git a/tardis/plasma/tests/test_complete_plasmas.py b/tardis/plasma/tests/test_complete_plasmas.py index ffbc25bc160..25f3b8cdb36 100644 --- a/tardis/plasma/tests/test_complete_plasmas.py +++ b/tardis/plasma/tests/test_complete_plasmas.py @@ -125,10 +125,10 @@ def config(self, request): return config @pytest.fixture(scope="class") - def plasma(self, chianti_he_db_fpath, config, tardis_ref_data): + def plasma(self, pytestconfig, chianti_he_db_fpath, config, tardis_ref_data): config['atom_data'] = chianti_he_db_fpath sim = Simulation.from_config(config) - if pytest.config.getvalue("--generate-reference"): + if pytestconfig.getvalue("--generate-reference"): sim.plasma.to_hdf(tardis_ref_data, path=config.plasma.save_path) pytest.skip("Reference data saved at {0}".format(tardis_ref_data)) return sim.plasma From fd68f174242eee9b1db6de45d42c4231cd0d7261 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ezequiel=20P=C3=A1ssaro?= Date: Thu, 11 Jun 2020 17:27:09 -0300 Subject: [PATCH 7/7] Pin pytest to 5 --- tardis_env3.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tardis_env3.yml b/tardis_env3.yml index ab07383b4fd..2c1c23f691d 100644 --- a/tardis_env3.yml +++ b/tardis_env3.yml @@ -52,7 +52,7 @@ dependencies: #Test/Coverage requirements - git-lfs - - pytest + - pytest=5 - pytest-html - requests - coverage