mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
testsuite/runtests.py (gettestnames): Cleanup
Original commit message from CVS: * testsuite/runtests.py (gettestnames): Cleanup * testsuite/element.py (FakeSinkTest): Enable again and disable stderr while changing state to ready (ElementName.testElementStateGetName): New function to test gst.element_state_get_name. * testsuite/common.py (path): Don't import ltihooks and proper check for gst module. Add --gst-debug-no-color as a global option (disable_stderr, enable_stderr): New functions to disable stdout called from non python
This commit is contained in:
parent
ca3eb4296c
commit
290df83671
5 changed files with 96 additions and 19 deletions
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
|||
2004-05-01 Johan Dahlin <johan@gnome.org>
|
||||
|
||||
* testsuite/runtests.py (gettestnames): Cleanup
|
||||
|
||||
* testsuite/element.py (FakeSinkTest): Enable again and disable
|
||||
stderr while changing state to ready
|
||||
(ElementName.testElementStateGetName): New function to test
|
||||
gst.element_state_get_name.
|
||||
|
||||
* testsuite/common.py (path): Don't import ltihooks and proper
|
||||
check for gst module. Add --gst-debug-no-color as a global option
|
||||
(disable_stderr, enable_stderr): New functions to disable stdout
|
||||
called from non python
|
||||
|
||||
2004-04-30 Johan Dahlin <johan@gnome.org>
|
||||
|
||||
* gst/gst.defs (element_state_get_name): Add.
|
||||
|
|
|
@ -4,16 +4,17 @@ import sys
|
|||
import unittest
|
||||
|
||||
# Don't insert before .
|
||||
sys.path.insert(1, os.path.join('..', 'gst'))
|
||||
|
||||
import ltihooks
|
||||
sys.path.insert(1, os.path.join('..'))
|
||||
|
||||
# Load GST and make sure we load it from the current build
|
||||
sys.setdlopenflags(dl.RTLD_LAZY | dl.RTLD_GLOBAL)
|
||||
|
||||
# Hack
|
||||
sys.argv.append('--gst-debug-no-color')
|
||||
|
||||
path = os.path.abspath(os.path.join('..', 'gst'))
|
||||
import gst
|
||||
assert gst.__path__ != path, 'bad path'
|
||||
assert gst._gst.__file__ == '../gst/_gst.la'
|
||||
|
||||
try:
|
||||
import gst.interfaces
|
||||
|
@ -27,5 +28,22 @@ try:
|
|||
except ImportError:
|
||||
pass
|
||||
|
||||
_stderr = None
|
||||
|
||||
def disable_stderr():
|
||||
global _stderr
|
||||
_stderr = file('/tmp/stderr', 'w+')
|
||||
sys.stderr = os.fdopen(os.dup(2), 'w')
|
||||
os.close(2)
|
||||
os.dup(_stderr.fileno())
|
||||
|
||||
def enable_stderr():
|
||||
global _stderr
|
||||
|
||||
os.close(2)
|
||||
os.dup(sys.stderr.fileno())
|
||||
_stderr.seek(0, 0)
|
||||
data = _stderr.read()
|
||||
_stderr.close()
|
||||
os.remove('/tmp/stderr')
|
||||
return data
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#
|
||||
# testsuite for gstreamer.Element
|
||||
|
||||
import common
|
||||
from common import gst, unittest
|
||||
|
||||
class ElementTest(unittest.TestCase):
|
||||
|
@ -32,8 +33,7 @@ class FakeSinkTest(ElementTest):
|
|||
def setUp(self):
|
||||
self.element = gst.Element('fakesink', 'sink')
|
||||
|
||||
# Disabled - since it outputs junks
|
||||
def _testStateError(self):
|
||||
def testStateError(self):
|
||||
self.element.set_property('state-error',
|
||||
self.FAKESINK_STATE_ERROR_NULL_READY)
|
||||
def error_cb(element, source, error, debug):
|
||||
|
@ -44,7 +44,9 @@ class FakeSinkTest(ElementTest):
|
|||
assert isinstance(error, gst.GError)
|
||||
|
||||
self.element.connect('error', error_cb)
|
||||
common.disable_stderr()
|
||||
self.element.set_state(gst.STATE_READY)
|
||||
common.enable_stderr()
|
||||
|
||||
class NonExistentTest(ElementTest):
|
||||
name = 'this-element-does-not-exist'
|
||||
|
@ -53,5 +55,21 @@ class NonExistentTest(ElementTest):
|
|||
def testGoodConstructor(self):
|
||||
pass
|
||||
|
||||
class ElementName(unittest.TestCase):
|
||||
def testElementStateGetName(self):
|
||||
get_name = gst.element_state_get_name
|
||||
for state in ('NULL',
|
||||
'READY',
|
||||
'PLAYING',
|
||||
'PAUSED'):
|
||||
name = 'STATE_' + state
|
||||
assert hasattr(gst, name)
|
||||
attr = getattr(gst, name)
|
||||
assert get_name(attr) == state
|
||||
|
||||
assert get_name(gst.STATE_VOID_PENDING) == 'NONE_PENDING'
|
||||
assert get_name(-1) == 'UNKNOWN!'
|
||||
self.assertRaises(TypeError, get_name, '')
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
|
@ -1,12 +1,21 @@
|
|||
#!/usr/bin/env python
|
||||
import glob
|
||||
import sys
|
||||
from unittest import TestSuite, TestLoader, TextTestRunner
|
||||
from types import ClassType
|
||||
import unittest
|
||||
|
||||
loader = TestLoader()
|
||||
testRunner = TextTestRunner()
|
||||
SKIP_FILES = ['common', 'runtests']
|
||||
|
||||
test = TestSuite()
|
||||
for name in ('element', 'interface', 'pipeline'):
|
||||
test.addTest(loader.loadTestsFromName(name))
|
||||
testRunner.run(tests)
|
||||
def gettestnames():
|
||||
files = glob.glob('*.py')
|
||||
names = map(lambda x: x[:-3], files)
|
||||
map(names.remove, SKIP_FILES)
|
||||
return names
|
||||
|
||||
suite = unittest.TestSuite()
|
||||
loader = unittest.TestLoader()
|
||||
|
||||
for name in gettestnames():
|
||||
suite.addTest(loader.loadTestsFromName(name))
|
||||
|
||||
testRunner = unittest.TextTestRunner()
|
||||
testRunner.run(suite)
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#
|
||||
# testsuite for gstreamer.Element
|
||||
|
||||
import common
|
||||
from common import gst, unittest
|
||||
|
||||
class ElementTest(unittest.TestCase):
|
||||
|
@ -32,8 +33,7 @@ class FakeSinkTest(ElementTest):
|
|||
def setUp(self):
|
||||
self.element = gst.Element('fakesink', 'sink')
|
||||
|
||||
# Disabled - since it outputs junks
|
||||
def _testStateError(self):
|
||||
def testStateError(self):
|
||||
self.element.set_property('state-error',
|
||||
self.FAKESINK_STATE_ERROR_NULL_READY)
|
||||
def error_cb(element, source, error, debug):
|
||||
|
@ -44,7 +44,9 @@ class FakeSinkTest(ElementTest):
|
|||
assert isinstance(error, gst.GError)
|
||||
|
||||
self.element.connect('error', error_cb)
|
||||
common.disable_stderr()
|
||||
self.element.set_state(gst.STATE_READY)
|
||||
common.enable_stderr()
|
||||
|
||||
class NonExistentTest(ElementTest):
|
||||
name = 'this-element-does-not-exist'
|
||||
|
@ -53,5 +55,21 @@ class NonExistentTest(ElementTest):
|
|||
def testGoodConstructor(self):
|
||||
pass
|
||||
|
||||
class ElementName(unittest.TestCase):
|
||||
def testElementStateGetName(self):
|
||||
get_name = gst.element_state_get_name
|
||||
for state in ('NULL',
|
||||
'READY',
|
||||
'PLAYING',
|
||||
'PAUSED'):
|
||||
name = 'STATE_' + state
|
||||
assert hasattr(gst, name)
|
||||
attr = getattr(gst, name)
|
||||
assert get_name(attr) == state
|
||||
|
||||
assert get_name(gst.STATE_VOID_PENDING) == 'NONE_PENDING'
|
||||
assert get_name(-1) == 'UNKNOWN!'
|
||||
self.assertRaises(TypeError, get_name, '')
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
Loading…
Reference in a new issue