Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #136 from labuzm/fix_wrapper
fix freeing of python wrapper
- Loading branch information
Showing
3 changed files
with
43 additions
and
7 deletions.
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,23 @@ | ||
import pytest | ||
|
||
from kaa.nodes import Node | ||
|
||
from tests.utils import TestScene | ||
|
||
|
||
class ChildNode(Node): | ||
def on_attach(self): | ||
assert self.parent | ||
|
||
def on_detach(self): | ||
# parent is already deleted | ||
assert not self.parent | ||
|
||
|
||
@pytest.mark.usefixtures('test_engine') | ||
def test_on_callbacks(): | ||
parent = Node() | ||
parent.add_child(ChildNode()) | ||
scene = TestScene(lambda scene, dt: parent.delete()) | ||
scene.root.add_child(parent) | ||
scene.run_on_engine(1) |
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,19 @@ | ||
from kaa.engine import Scene | ||
|
||
|
||
class TestScene(Scene): | ||
def __init__(self, update_function): | ||
self._frames = None | ||
self._test_update_function = update_function | ||
|
||
def update(self, dt): | ||
if self._frames == 0: | ||
self.engine.quit() | ||
return | ||
|
||
self._test_update_function(self, dt) | ||
self._frames -= 1 | ||
|
||
def run_on_engine(self, frames): | ||
self._frames = frames | ||
self.engine.run(self) |