Skip to content

Commit

Permalink
Add some initial tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
bilderbuchi committed Nov 18, 2018
1 parent 654b6b1 commit 0290c64
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 4 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,16 @@ Make sure you have **Python 3.4** or better on your computer.
To install pyno you must run ```pip install .``` from this directory.
Pyno's dependencies `pyglet` and `pyperclip` are going to be installed automatically.
Then run ```pyno``` in a console.

# How to modify

To develop/modify code, you can install Pyno in "developer mode" by running `pip install -e .` in the Pyno directory.
This runs setup.py and installs a link to the `pyno` directory, as if it were normally installed.

To run the tests, you need `pytest` installed.
You run `pytest` in the root directory of the repository.
It will discover the tests in the `tests` directory and run them on the installed package.
You will see a couple of flashing windows when they get instantiated.

If you have (on Linux) `xvfb` and the pytest plugin `pytest-xvfb` installed, the tests should automatically be run on the virtual framebuffer, so no windows should become visible.
If this for some reason does not work, invoking pytest via `xvfb-run pytest` should do the trick.
11 changes: 8 additions & 3 deletions pyno/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,13 @@ def paste_nodes(self):

def app_run():
print('Loading...')
window = get_window() # Not using this for anything
pyglet.options['debug_gl'] = False # performance boost?
# profile.run('pyglet.app.run()', sort=1)
pyglet.app.run()


def get_window():
config = pyglet.gl.Config(double_buffer=True, depth_size=0,
stencil_size=0, aux_buffers=0,
samples=1)
Expand All @@ -459,6 +466,4 @@ def app_run():
except:
# if config is crashed run more default one
pwindow = PynoWindow(pyglet.gl.Config(), filename='.auto-saved.pn')
pyglet.options['debug_gl'] = False # performance boost?
# profile.run('pyglet.app.run()', sort=1)
pyglet.app.run()
return pwindow
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
packages=find_packages(exclude=['docs', 'tests']),
install_requires=['pyglet', 'pyperclip'],
extras_require={
'test': ['pytest', 'coverage'],
'test': ['pytest'],
},
package_data={
'pyno': ['imgs/*.png', 'examples/*.pn'],
Expand Down
11 changes: 11 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""This contains e.g. fixtures that supply reusable elements."""

import pytest

import pyno.window


@pytest.fixture
def window():
"""Supply a window, as that will probably be useful quite often."""
return pyno.window.get_window()
3 changes: 3 additions & 0 deletions tests/test_element.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""Tests for pyno.element"""

pass
17 changes: 17 additions & 0 deletions tests/test_window.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"""Tests for pyno.window"""
import pyglet

from pyno import window


def test_app_run():
pyglet.clock.schedule_once(lambda x: pyglet.app.exit(), 0.1)
window.app_run()


def test_get_window(window):
# Check some meaningful things
assert window.caption == 'Pyno'
assert window.active_nodes == []


0 comments on commit 0290c64

Please sign in to comment.