From 729a59d947cc5d810240b700be4aea72b6cd5a1f Mon Sep 17 00:00:00 2001 From: Martin Bauer <martin.bauer@fau.de> Date: Fri, 16 Aug 2019 14:12:39 +0200 Subject: [PATCH] pytest.raises: checking for exception error message fixed - str(e) did work in previous pytest version - but the correct usage is str(e.value) - in newer pytest version the string for the e object is changed so the tests did not work any more --- lbmpy_tests/test_lbstep.py | 2 +- lbmpy_tests/test_relaxation_rate.py | 2 +- lbmpy_tests/test_stencils.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lbmpy_tests/test_lbstep.py b/lbmpy_tests/test_lbstep.py index e490344..7d6d395 100644 --- a/lbmpy_tests/test_lbstep.py +++ b/lbmpy_tests/test_lbstep.py @@ -92,7 +92,7 @@ def test_advanced_initialization(): shear_flow_scenario = create_fully_periodic_flow(initial_velocity=init_vel, relaxation_rate=1.95) with pytest.raises(ValueError) as e: shear_flow_scenario.run_iterative_initialization(max_steps=20000, check_residuum_after=500) - assert 'did not converge' in str(e) + assert 'did not converge' in str(e.value) shear_flow_scenario = create_fully_periodic_flow(initial_velocity=init_vel, relaxation_rate=1.6) shear_flow_scenario.run_iterative_initialization(max_steps=20000, check_residuum_after=500) diff --git a/lbmpy_tests/test_relaxation_rate.py b/lbmpy_tests/test_relaxation_rate.py index 1d8fb6a..39ce082 100644 --- a/lbmpy_tests/test_relaxation_rate.py +++ b/lbmpy_tests/test_relaxation_rate.py @@ -9,7 +9,7 @@ def test_relaxation_rate(): relaxation_rates=[1 + i / 10 for i in range(19)]) with pytest.raises(ValueError) as e: get_shear_relaxation_rate(method) - assert 'Shear moments are relaxed with different relaxation' in str(e) + assert 'Shear moments are relaxed with different relaxation' in str(e.value) method = create_lb_method(stencil="D2Q9", method='mrt_raw', relaxation_rates=[1 + i / 10 for i in range(9)]) diff --git a/lbmpy_tests/test_stencils.py b/lbmpy_tests/test_stencils.py index 253c321..eb07afc 100644 --- a/lbmpy_tests/test_stencils.py +++ b/lbmpy_tests/test_stencils.py @@ -67,7 +67,7 @@ def test_free_functions(): with pytest.raises(ValueError) as e: get_stencil("name_that_does_not_exist") - assert "No such stencil" in str(e) + assert "No such stencil" in str(e.value) def test_visualize(): -- GitLab