more sensible tests

This commit is contained in:
Martin Diehl 2020-08-25 17:17:49 +02:00
parent bf401e56cf
commit fee21cbd9c
2 changed files with 12 additions and 6 deletions

View File

@ -171,6 +171,10 @@ class TestGeom:
def test_flip_invariant(self,default):
assert geom_equal(default,default.flip([]))
@pytest.mark.parametrize('direction',[['x'],['x','y']])
def test_flip_double(self,default,direction):
assert geom_equal(default,default.flip(direction).flip(direction))
@pytest.mark.parametrize('directions',[(1,2,'y'),('a','b','x'),[1]])
def test_flip_invalid(self,default,directions):
with pytest.raises(ValueError):

View File

@ -100,15 +100,18 @@ class TestVTK:
with pytest.raises(ValueError):
default.get('does_not_exist')
@pytest.mark.parametrize('data,label',[(np.ones(3),'valid'),
(np.ones(3),None)])
def test_invalid_add(self,default,data,label):
def test_invalid_add_shape(self,default):
with pytest.raises(ValueError):
default.add(np.ones(3),label)
default.add(np.ones(3),'valid')
def test_invalid_add_missing_label(self,default):
data = np.random.randint(9,size=np.prod(np.array(default.vtk_data.GetDimensions())-1))
with pytest.raises(ValueError):
default.add(data)
def test_invalid_add_type(self,default):
with pytest.raises(TypeError):
default.add('invalid_type','label')
default.add('invalid_type','valid')
def test_comments(self,tmp_path,default):
default.add_comments(['this is a comment'])
@ -116,7 +119,6 @@ class TestVTK:
new = VTK.from_file(tmp_path/'with_comments.vtr')
assert new.get_comments() == ['this is a comment']
def test_compare_reference_polyData(self,update,reference_dir,tmp_path):
points=np.dstack((np.linspace(0.,1.,10),np.linspace(0.,2.,10),np.linspace(-1.,1.,10))).squeeze()
polyData = VTK.from_polyData(points)