Skip to content

Commit

Permalink
Upgrade pytest version (#1185)
Browse files Browse the repository at this point in the history
* Unpin pytest version from environment file

* Fix integration tests skip condition

* Revert "Fix integration tests skip condition"

This reverts commit bb170bf.

* Trying new solution

* Using `pytestconfig`

* Using `pytestconfig` (2)

* Pin pytest to 5
  • Loading branch information
epassaro authored Jun 12, 2020
1 parent 6056f3b commit e5e2919
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion azure-pipelines/simple_test_framework.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 4 additions & 4 deletions tardis/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,17 @@ 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:
return option


@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:
Expand Down
4 changes: 2 additions & 2 deletions tardis/montecarlo/tests/test_packet_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
4 changes: 2 additions & 2 deletions tardis/plasma/tests/test_complete_plasmas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tardis/tests/integration_tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion tardis_env3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ dependencies:

#Test/Coverage requirements
- git-lfs
- pytest=4
- pytest=5
- pytest-html
- requests
- coverage
Expand Down

0 comments on commit e5e2919

Please sign in to comment.