split into two tests, one will fail on Ubuntu

This commit is contained in:
Martin Diehl 2021-06-19 08:12:49 +02:00
parent 56b011aa54
commit 71634f6ce9
1 changed files with 24 additions and 12 deletions

View File

@ -405,7 +405,7 @@ class TestResult:
os.chdir(tmp_path) os.chdir(tmp_path)
single_phase.save_VTK(mode=mode) single_phase.save_VTK(mode=mode)
def test_XDMF(self,tmp_path,single_phase,update,ref_path): def test_XDMF_datatypes(self,tmp_path,single_phase,update,ref_path):
for shape in [('scalar',()),('vector',(3,)),('tensor',(3,3)),('matrix',(12,))]: for shape in [('scalar',()),('vector',(3,)),('tensor',(3,3)),('matrix',(12,))]:
for dtype in ['f4','f8','i1','i2','i4','i8','u1','u2','u4','u8']: for dtype in ['f4','f8','i1','i2','i4','i8','u1','u2','u4','u8']:
single_phase.add_calculation(f"np.ones(np.shape(#F#)[0:1]+{shape[1]},'{dtype}')",f'{shape[0]}_{dtype}') single_phase.add_calculation(f"np.ones(np.shape(#F#)[0:1]+{shape[1]},'{dtype}')",f'{shape[0]}_{dtype}')
@ -413,25 +413,37 @@ class TestResult:
os.chdir(tmp_path) os.chdir(tmp_path)
single_phase.save_XDMF() single_phase.save_XDMF()
single_phase.view('increments',0).save_VTK()
if update:
shutil.copy(tmp_path/fname,ref_path/fname)
assert sorted(open(tmp_path/fname).read()) == sorted(open(ref_path/fname).read()) # XML is not ordered
@pytest.mark.skipif(not hasattr(vtk,'vtkXdmfReader'),reason='https://discourse.vtk.org/t/2450')
def test_XDMF_shape(self,tmp_path,single_phase):
os.chdir(tmp_path)
single_phase.save_XDMF()
fname = os.path.splitext(os.path.basename(single_phase.fname))[0]+'.xdmf'
reader_xdmf = vtk.vtkXdmfReader() reader_xdmf = vtk.vtkXdmfReader()
reader_xdmf.SetFileName(fname) reader_xdmf.SetFileName(fname)
reader_xdmf.Update() reader_xdmf.Update()
dim_xdmf = reader_xdmf.GetOutput().GetDimensions() dim_xdmf = reader_xdmf.GetOutput().GetDimensions()
bounds_xdmf = reader_xdmf.GetOutput().GetBounds() bounds_xdmf = reader_xdmf.GetOutput().GetBounds()
reader_vti = vtk.vtkXMLImageDataReader() single_phase.view('increments',0).save_VTK()
reader_vti.SetFileName(os.path.splitext(fname)[0]+'_inc00.vti') fname = os.path.splitext(os.path.basename(single_phase.fname))[0]+'_inc00.vti'
reader_vti.Update() for i in range(10): # waiting for parallel IO
dim_vti = reader_vti.GetOutput().GetDimensions() reader_vti = vtk.vtkXMLImageDataReader()
bounds_vti = reader_vti.GetOutput().GetBounds() reader_vti.SetFileName(fname)
reader_vti.Update()
dim_vti = reader_vti.GetOutput().GetDimensions()
bounds_vti = reader_vti.GetOutput().GetBounds()
if dim_vti == dim_xdmf and bounds_vti == bounds_xdmf:
return
time.sleep(.5)
if update: assert False
shutil.copy(tmp_path/fname,ref_path/fname)
assert dim_vti == dim_xdmf and bounds_vti == bounds_xdmf and \
sorted(open(tmp_path/fname).read()) == sorted(open(ref_path/fname).read()) # XML is not ordered
def test_XDMF_invalid(self,default): def test_XDMF_invalid(self,default):
with pytest.raises(TypeError): with pytest.raises(TypeError):