test_triangle.py 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import pytest
  2. from freesurfer_surface import Triangle
  3. def test_init():
  4. triangle = Triangle((0, 21, 42))
  5. assert triangle.vertex_indices == (0, 21, 42)
  6. def test_init_invalid_indices_len():
  7. with pytest.raises(Exception):
  8. Triangle((0, 21, 42, 84))
  9. def test_reassign_vertex_indices():
  10. triangle = Triangle((0, 21, 42))
  11. triangle.vertex_indices = (1, 2, 3)
  12. assert triangle.vertex_indices == (1, 2, 3)
  13. def test_reassign_vertex_indices_invalid_len():
  14. triangle = Triangle((0, 21, 42))
  15. with pytest.raises(Exception):
  16. triangle.vertex_indices = (1, 2, 3, 4)
  17. def test_eq():
  18. assert Triangle((0, 1, 2)) == Triangle((0, 1, 2))
  19. assert Triangle((0, 1, 2)) == Triangle((1, 2, 0))
  20. # pylint: disable=unneeded-not
  21. assert not Triangle((0, 1, 2)) == Triangle((0, 1, 4))
  22. assert not Triangle((0, 1, 2)) == Triangle((0, 4, 2))
  23. assert not Triangle((0, 1, 2)) == Triangle((4, 1, 2))
  24. def test_repr():
  25. assert repr(Triangle((0, 1, 2))) == 'Triangle(vertex_indices=(0, 1, 2))'