expand test coverage
This commit is contained in:
parent
3bac04a456
commit
e6909804f0
@ -36,7 +36,7 @@ def quit_sub_system(flags):
|
||||
errcheck(_SDL.SDL_QuitSubSystem(flags))
|
||||
|
||||
def was_init(flags=0):
|
||||
errcheck(_SDL.SDL_WasInit(flags))
|
||||
return errcheck(_SDL.SDL_WasInit(flags))
|
||||
|
||||
def quit():
|
||||
_SDL.SDL_Quit()
|
||||
|
52
csdl/tests/test_basics.py
Normal file
52
csdl/tests/test_basics.py
Normal file
@ -0,0 +1,52 @@
|
||||
import csdl
|
||||
from nose.tools import with_setup
|
||||
|
||||
def test_error_handling():
|
||||
# blank by default
|
||||
assert csdl.get_error() == ""
|
||||
|
||||
# check set
|
||||
csdl.set_error("test!")
|
||||
assert csdl.get_error() == "test!"
|
||||
|
||||
# check again, shouldn't clear
|
||||
assert csdl.get_error() == "test!"
|
||||
|
||||
# clear again
|
||||
csdl.clear_error()
|
||||
assert csdl.get_error() == ""
|
||||
|
||||
@with_setup(csdl.quit)
|
||||
def test_init():
|
||||
csdl.init(csdl.InitFlags.EVERYTHING)
|
||||
# everything should include these
|
||||
assert csdl.was_init(csdl.InitFlags.TIMER|csdl.InitFlags.AUDIO|
|
||||
csdl.InitFlags.VIDEO|csdl.InitFlags.JOYSTICK|
|
||||
csdl.InitFlags.HAPTIC)
|
||||
|
||||
@with_setup(csdl.quit)
|
||||
def test_quit():
|
||||
csdl.init(csdl.InitFlags.EVERYTHING)
|
||||
csdl.quit()
|
||||
assert csdl.was_init(0) == 0
|
||||
|
||||
@with_setup(csdl.quit)
|
||||
def test_init_sub_system():
|
||||
csdl.init_sub_system(csdl.InitFlags.TIMER)
|
||||
assert csdl.was_init(csdl.InitFlags.TIMER)
|
||||
|
||||
@with_setup(csdl.quit)
|
||||
def test_quit_sub_system():
|
||||
csdl.init_sub_system(csdl.InitFlags.TIMER)
|
||||
assert csdl.was_init(csdl.InitFlags.TIMER)
|
||||
csdl.quit_sub_system(csdl.InitFlags.TIMER)
|
||||
assert not csdl.was_init(csdl.InitFlags.TIMER)
|
||||
|
||||
def test_version():
|
||||
v = csdl.get_version()
|
||||
assert repr(v).startswith('Version')
|
||||
assert str(v).startswith('1.3')
|
||||
assert v.major == 1 and v.minor == 3
|
||||
|
||||
def test_revision():
|
||||
assert csdl.get_revision().startswith('hg')
|
@ -1,4 +1,5 @@
|
||||
from csdl.enum import CEnum, CEnumSymbol
|
||||
import nose.tools
|
||||
|
||||
class TestEnum(CEnum):
|
||||
FIRST = 0
|
||||
@ -18,6 +19,10 @@ def test_enumsymbol():
|
||||
|
||||
def test_cenum():
|
||||
assert len(TestEnum.values()) == 3
|
||||
assert len(list(iter(TestEnum))) == 3
|
||||
|
||||
def test_cenum_from_int():
|
||||
big_hopefully = TestEnum.from_int(9001)
|
||||
assert isinstance(big_hopefully, CEnumSymbol)
|
||||
assert big_hopefully.name == 'BIG'
|
||||
nose.tools.assert_raises(ValueError, TestEnum.from_int, 50)
|
||||
|
15
csdl/tests/test_sysinfo.py
Normal file
15
csdl/tests/test_sysinfo.py
Normal file
@ -0,0 +1,15 @@
|
||||
from csdl import sysinfo
|
||||
|
||||
def test_get_platform():
|
||||
assert isinstance(sysinfo.get_platform(), str)
|
||||
|
||||
def test_cpu_info():
|
||||
assert sysinfo.get_cpu_cache_line_size() > 0
|
||||
assert sysinfo.get_cpu_count() > 0
|
||||
|
||||
def test_power_info():
|
||||
state, seconds, percent = sysinfo.get_power_info()
|
||||
assert state in ('UNKNOWN', 'ON_BATTERY', 'NO_BATTERY', 'CHARGING',
|
||||
'CHARGED')
|
||||
assert isinstance(seconds, int)
|
||||
assert isinstance(percent, int)
|
Loading…
Reference in New Issue
Block a user