photon/csdl/tests/test_basics.py

56 lines
1.4 KiB
Python
Raw Normal View History

from .. import (get_error, set_error, clear_error,
InitFlags, init, quit, was_init,
init_sub_system, quit_sub_system,
get_version, get_revision)
2011-03-28 04:22:31 +00:00
from nose.tools import with_setup
def test_error_handling():
# blank by default
assert get_error() == ""
2011-03-28 04:22:31 +00:00
# check set
set_error("test!")
assert get_error() == "test!"
2011-03-28 04:22:31 +00:00
# check again, shouldn't clear
assert get_error() == "test!"
2011-03-28 04:22:31 +00:00
# clear again
clear_error()
assert get_error() == ""
2011-03-28 04:22:31 +00:00
@with_setup(quit)
2011-03-28 04:22:31 +00:00
def test_init():
init(InitFlags.EVERYTHING)
2011-03-28 04:22:31 +00:00
# everything should include these
assert was_init(InitFlags.TIMER|InitFlags.AUDIO|
InitFlags.VIDEO|InitFlags.JOYSTICK|
InitFlags.HAPTIC)
2011-03-28 04:22:31 +00:00
@with_setup(quit)
2011-03-28 04:22:31 +00:00
def test_quit():
init(InitFlags.EVERYTHING)
quit()
assert was_init(0) == 0
2011-03-28 04:22:31 +00:00
@with_setup(quit)
2011-03-28 04:22:31 +00:00
def test_init_sub_system():
init_sub_system(InitFlags.TIMER)
assert was_init(InitFlags.TIMER)
2011-03-28 04:22:31 +00:00
@with_setup(quit)
2011-03-28 04:22:31 +00:00
def test_quit_sub_system():
init_sub_system(InitFlags.TIMER)
assert was_init(InitFlags.TIMER)
quit_sub_system(InitFlags.TIMER)
assert not was_init(InitFlags.TIMER)
2011-03-28 04:22:31 +00:00
def test_version():
v = get_version()
2011-03-28 04:22:31 +00:00
assert repr(v).startswith('Version')
assert str(v).startswith('1.3')
assert v.major == 1 and v.minor == 3
def test_revision():
assert get_revision().startswith('hg')