2011-04-27 04:08:21 +00:00
|
|
|
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
|
2011-04-27 04:08:21 +00:00
|
|
|
assert get_error() == ""
|
2011-03-28 04:22:31 +00:00
|
|
|
|
|
|
|
# check set
|
2011-04-27 04:08:21 +00:00
|
|
|
set_error("test!")
|
|
|
|
assert get_error() == "test!"
|
2011-03-28 04:22:31 +00:00
|
|
|
|
|
|
|
# check again, shouldn't clear
|
2011-04-27 04:08:21 +00:00
|
|
|
assert get_error() == "test!"
|
2011-03-28 04:22:31 +00:00
|
|
|
|
|
|
|
# clear again
|
2011-04-27 04:08:21 +00:00
|
|
|
clear_error()
|
|
|
|
assert get_error() == ""
|
2011-03-28 04:22:31 +00:00
|
|
|
|
2011-04-27 04:08:21 +00:00
|
|
|
@with_setup(quit)
|
2011-03-28 04:22:31 +00:00
|
|
|
def test_init():
|
2011-04-27 04:08:21 +00:00
|
|
|
init(InitFlags.EVERYTHING)
|
2011-03-28 04:22:31 +00:00
|
|
|
# everything should include these
|
2011-04-27 04:08:21 +00:00
|
|
|
assert was_init(InitFlags.TIMER|InitFlags.AUDIO|
|
|
|
|
InitFlags.VIDEO|InitFlags.JOYSTICK|
|
|
|
|
InitFlags.HAPTIC)
|
2011-03-28 04:22:31 +00:00
|
|
|
|
2011-04-27 04:08:21 +00:00
|
|
|
@with_setup(quit)
|
2011-03-28 04:22:31 +00:00
|
|
|
def test_quit():
|
2011-04-27 04:08:21 +00:00
|
|
|
init(InitFlags.EVERYTHING)
|
|
|
|
quit()
|
|
|
|
assert was_init(0) == 0
|
2011-03-28 04:22:31 +00:00
|
|
|
|
2011-04-27 04:08:21 +00:00
|
|
|
@with_setup(quit)
|
2011-03-28 04:22:31 +00:00
|
|
|
def test_init_sub_system():
|
2011-04-27 04:08:21 +00:00
|
|
|
init_sub_system(InitFlags.TIMER)
|
|
|
|
assert was_init(InitFlags.TIMER)
|
2011-03-28 04:22:31 +00:00
|
|
|
|
2011-04-27 04:08:21 +00:00
|
|
|
@with_setup(quit)
|
2011-03-28 04:22:31 +00:00
|
|
|
def test_quit_sub_system():
|
2011-04-27 04:08:21 +00:00
|
|
|
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():
|
2011-04-27 04:08:21 +00:00
|
|
|
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():
|
2011-04-27 04:08:21 +00:00
|
|
|
assert get_revision().startswith('hg')
|