Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manual Testing #328

Merged
merged 2 commits into from
Jul 23, 2019
Merged
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
7 changes: 7 additions & 0 deletions viztests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Visual Tests
============

This is a test suite of manual tests, meant to help with the difficulty of
thorough automated testing of graphical software.

Run with `python -m viztests`
24 changes: 24 additions & 0 deletions viztests/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import ast
from pathlib import Path
import subprocess
import sys


def get_docstring(path):
tree = ast.parse(path.read_text(), path.name, mode='exec')

return ast.get_docstring(tree)


for script in Path(__file__).resolve().parent.glob('*.py'):
if script.name.startswith('_'):
continue
ds = get_docstring(script)
print("=" * len(script.name))
print(script.name)
print("=" * len(script.name))
print("")
if ds is not None:
print(ds)
print("")
subprocess.run([sys.executable, str(script)], check=True)
31 changes: 31 additions & 0 deletions viztests/angles.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""
Tests rotation vs Vector angles

The center sprite should always face the orbiting sprite
"""
import ppb

ROTATION_RATE = 90


class CenterSprite(ppb.BaseSprite):
image = ppb.Image('player.png')

def on_update(self, event, signal):
self.rotation += ROTATION_RATE * event.time_delta


class OrbitSprite(ppb.BaseSprite):
position = ppb.Vector(0, -2)
image = ppb.Image('target.png')

def on_update(self, event, signal):
self.position = self.position.rotate(ROTATION_RATE * event.time_delta)


def setup(scene):
scene.add(CenterSprite())
scene.add(OrbitSprite())


ppb.run(setup)
Binary file added viztests/bullet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added viztests/player.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added viztests/target.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.