Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/sfml/graphics/graphics.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ cdef public class Rect[type PyRectType, object PyRectObject]:
elif op == 3:
return tuple(self) != tuple(other)
else:
raise NotImplemented
return NotImplemented

def __iter__(self):
return iter((self.left, self.top, self.width, self.height))
Expand Down
16 changes: 16 additions & 0 deletions tests/test_graphics_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,22 @@ def test_rect_color_and_transform_behaviors_are_deterministic():
assert transform.rotate(15) is transform


def test_rect_ordering_is_not_supported():
left = sf.Rect((0, 0), (4, 4))
right = sf.Rect((0, 0), (4, 4))

assert left == right
assert not (left != right)

with pytest.raises(TypeError) as excinfo:
left > right

message = str(excinfo.value)
assert "not supported" in message
assert "Rect" in message
assert "BaseException" not in message


def test_render_texture_uses_explicit_activation_api_and_exposes_texture():
render_texture = sf.RenderTexture(8, 8)

Expand Down
17 changes: 14 additions & 3 deletions tests/test_system_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,19 @@ def test_vector2_inplace_operations():


def test_vector2_ordering_is_not_supported():
with pytest.raises(TypeError):
sf.Vector2(1, 2) < sf.Vector2(2, 3)
left = sf.Vector2(1, 2)
right = sf.Vector2(1, 2)

assert left == right
assert not (left != right)

with pytest.raises(TypeError) as excinfo:
left > right

message = str(excinfo.value)
assert "not supported" in message
assert "Vector2" in message
assert "BaseException" not in message


def test_vector3_sequence_interop_and_scalar_arithmetic():
Expand Down Expand Up @@ -192,4 +203,4 @@ def test_angle_arithmetic_and_inplace_operations():
assert angle.degrees == pytest.approx(40.0)

angle %= sf.degrees(15)
assert angle.degrees == pytest.approx(10.0)
assert angle.degrees == pytest.approx(10.0)