-
Notifications
You must be signed in to change notification settings - Fork 313
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't draw spritelists with alpha 0 + tests (#1640)
- Loading branch information
Showing
2 changed files
with
31 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import pytest | ||
import arcade | ||
from arcade.gl import Geometry | ||
|
||
|
||
def test_visible(window, monkeypatch): | ||
"""Ensure invisible spritelists are not drawn""" | ||
sp = arcade.SpriteList() | ||
# Monkeypatch Geometry.render to raise an error if called | ||
def mock_draw(*args, **kwargs): | ||
raise AssertionError("Should not be called") | ||
monkeypatch.setattr(Geometry, "render", mock_draw) | ||
|
||
# Empty spritelist should not be rendered | ||
sp.draw() | ||
|
||
# It will draw if it has sprites | ||
sp.append(arcade.SpriteSolidColor(10, 10, color=arcade.color.RED)) | ||
# Geometry.render should be called | ||
with pytest.raises(AssertionError): | ||
sp.draw() | ||
|
||
# Invisible should not be rendered | ||
sp.visible = False | ||
sp.draw() | ||
sp.visible = True | ||
|
||
# Alpha 0 should not be rendered | ||
sp.alpha = 0 | ||
sp.draw() |