Skip to content

Commit 3d25912

Browse files
committed
Test __str___ but not __repr__
Because newer float format behavior is different in different python versions
1 parent bf90aba commit 3d25912

File tree

5 files changed

+34
-8
lines changed

5 files changed

+34
-8
lines changed

tests/compas/geometry/test_frame.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,9 @@ def test_frame_data():
5555
assert Frame.validate_data(other.__data__)
5656

5757

58-
def test_frame_str_repr():
58+
def test_frame_str():
5959
frame = Frame.worldXY()
6060
assert str(frame) == "Frame(point=Point(x=0.000, y=0.000, z=0.000), xaxis=Vector(x=1.000, y=0.000, z=0.000), yaxis=Vector(x=0.000, y=1.000, z=0.000))"
61-
assert repr(frame) == "Frame(point=Point(x=0.0, y=0.0, z=0.0), xaxis=Vector(x=1.0, y=0.0, z=0.0), yaxis=Vector(x=0.0, y=1.0, z=0.0))"
6261

6362

6463
def test_frame_predefined():

tests/compas/geometry/test_plane.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,9 @@ def test_plane_data():
4646
assert Plane.validate_data(other.__data__)
4747

4848

49-
def test_plane_str_repr():
49+
def test_plane_str():
5050
plane = Plane.worldXY()
5151
assert str(plane) == "Plane(point=Point(x=0.000, y=0.000, z=0.000), normal=Vector(x=0.000, y=0.000, z=1.000))"
52-
assert repr(plane) == "Plane(point=Point(x=0.0, y=0.0, z=0.0), normal=Vector(x=0.0, y=0.0, z=1.0))"
5352

5453

5554
def test_plane_predefined():

tests/compas/geometry/test_polygon.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,10 @@ def test_polygon_data():
5252
assert Polygon.validate_data(other.__data__)
5353

5454

55-
def test_polygon_str_repr():
55+
def test_polygon_str():
5656
points = [[0, 0, x] for x in range(3)]
5757
polygon = Polygon(points)
5858
assert str(polygon) == "Polygon(points=[Point(x=0.000, y=0.000, z=0.000), Point(x=0.000, y=0.000, z=1.000), Point(x=0.000, y=0.000, z=2.000)])"
59-
assert repr(polygon) == "Polygon(points=[Point(x=0.0, y=0.0, z=0.0), Point(x=0.0, y=0.0, z=1.0), Point(x=0.0, y=0.0, z=2.0)])"
6059

6160

6261
def test_polygon__eq__():
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import pytest
2+
import json
3+
import compas
4+
from random import random
5+
from compas.geometry import Point
6+
from compas.geometry import Polyhedron
7+
from compas.itertools import pairwise
8+
9+
10+
def test_polyhedron():
11+
vertices = [[0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0]]
12+
faces = [[0, 1, 2, 3]]
13+
name = "Test Polyhedron"
14+
polyhedron = Polyhedron(vertices, faces, name)
15+
16+
assert polyhedron.vertices == vertices
17+
assert polyhedron.faces == faces
18+
assert polyhedron.name == name
19+
assert polyhedron.points == vertices
20+
assert polyhedron.lines == [(a, b) for a, b in pairwise(vertices + vertices[:1])]
21+
assert polyhedron.points[0] == vertices[0]
22+
assert polyhedron.points[-1] != polyhedron.points[0]
23+
24+
25+
def test_polyhedron_str():
26+
vertices = [[0, 0, 0], [1, 0, 0], [1, 1, 0]]
27+
faces = [[0, 1, 2]]
28+
polyhedron = Polyhedron(vertices, faces)
29+
30+
assert str(polyhedron) == "Polyhedron(vertices=[['0.000', '0.000', '0.000'], ['1.000', '0.000', '0.000'], ['1.000', '1.000', '0.000']], faces=[[0, 1, 2]])"

tests/compas/geometry/test_quaternion.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,9 @@ def test_quaternion_data():
6464
assert Quaternion.validate_data(other.__data__)
6565

6666

67-
def test_quaternion_str_repr():
67+
def test_quaternion_str():
6868
quaternion = Quaternion(0.5, 0.5, 0.5, 0.5)
6969
assert str(quaternion) == "Quaternion(0.500, 0.500, 0.500, 0.500)"
70-
assert repr(quaternion) == "Quaternion(0.5, 0.5, 0.5, 0.5)"
7170

7271

7372
# =============================================================================

0 commit comments

Comments
 (0)