gstreamer/testsuite/common.py
Johan Dahlin 290df83671 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
2004-05-01 15:35:32 +00:00

49 lines
1,020 B
Python

import dl
import os
import sys
import unittest
# Don't insert before .
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._gst.__file__ == '../gst/_gst.la'
try:
import gst.interfaces
assert os.path.basename(gst.interfaces.__file__) != path, 'bad path'
except ImportError:
pass
try:
import gst.play
assert os.path.basename(gst.play.__file__) != path, 'bad path'
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