From 670e08468be1cc67d53dc1b41796bd5113c4ca94 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 26 May 2020 06:49:29 +0200 Subject: [PATCH] reorder tests depend on other functionality that should be tested first --- python/tests/test_Result.py | 58 ++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/python/tests/test_Result.py b/python/tests/test_Result.py index 92e61771f..772cf4734 100644 --- a/python/tests/test_Result.py +++ b/python/tests/test_Result.py @@ -83,35 +83,6 @@ class TestResult: with pytest.raises(AttributeError): default.pick('invalid',True) - def test_add_invalid(self,default): - with pytest.raises(TypeError): - default.add_calculation('#invalid#*2') - - @pytest.mark.parametrize('overwrite',['off','on']) - def test_add_overwrite(self,default,overwrite): - default.pick('times',default.times_in_range(0,np.inf)[-1]) - - default.add_Cauchy() - loc = default.get_dataset_location('sigma')[0] - with h5py.File(default.fname,'r') as f: - created_first = f[loc].attrs['Created'].decode() - created_first = datetime.strptime(created_first,'%Y-%m-%d %H:%M:%S%z') - - if overwrite == 'on': - default.enable_overwrite() - else: - default.disable_overwrite() - - time.sleep(2.) - default.add_calculation('sigma','#sigma#*0.0+311.','not the Cauchy stress') - with h5py.File(default.fname,'r') as f: - created_second = f[loc].attrs['Created'].decode() - created_second = datetime.strptime(created_second,'%Y-%m-%d %H:%M:%S%z') - if overwrite == 'on': - assert created_first < created_second and np.allclose(default.read_dataset(loc),311.) - else: - assert created_first == created_second and not np.allclose(default.read_dataset(loc),311.) - def test_add_absolute(self,default): default.add_absolute('Fe') loc = {'Fe': default.get_dataset_location('Fe'), @@ -291,6 +262,35 @@ class TestResult: in_file = default.read_dataset(loc['V(F)'],0) assert np.allclose(in_memory,in_file) + def test_add_invalid(self,default): + with pytest.raises(TypeError): + default.add_calculation('#invalid#*2') + + @pytest.mark.parametrize('overwrite',['off','on']) + def test_add_overwrite(self,default,overwrite): + default.pick('times',default.times_in_range(0,np.inf)[-1]) + + default.add_Cauchy() + loc = default.get_dataset_location('sigma')[0] + with h5py.File(default.fname,'r') as f: + created_first = f[loc].attrs['Created'].decode() + created_first = datetime.strptime(created_first,'%Y-%m-%d %H:%M:%S%z') + + if overwrite == 'on': + default.enable_overwrite() + else: + default.disable_overwrite() + + time.sleep(2.) + default.add_calculation('sigma','#sigma#*0.0+311.','not the Cauchy stress') + with h5py.File(default.fname,'r') as f: + created_second = f[loc].attrs['Created'].decode() + created_second = datetime.strptime(created_second,'%Y-%m-%d %H:%M:%S%z') + if overwrite == 'on': + assert created_first < created_second and np.allclose(default.read_dataset(loc),311.) + else: + assert created_first == created_second and not np.allclose(default.read_dataset(loc),311.) + @pytest.mark.parametrize('output',['F',[],['F','P']]) def test_vtk(self,tmp_path,default,output): os.chdir(tmp_path)