2004-03-17 12:41:08 +00:00
|
|
|
import dl
|
2004-03-08 19:22:15 +00:00
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import unittest
|
|
|
|
|
2004-04-16 13:56:39 +00:00
|
|
|
# Don't insert before .
|
2004-05-01 15:35:32 +00:00
|
|
|
sys.path.insert(1, os.path.join('..'))
|
2004-03-17 12:41:08 +00:00
|
|
|
|
2004-04-16 13:56:39 +00:00
|
|
|
# Load GST and make sure we load it from the current build
|
2004-03-17 12:41:08 +00:00
|
|
|
sys.setdlopenflags(dl.RTLD_LAZY | dl.RTLD_GLOBAL)
|
|
|
|
|
2004-05-01 15:35:32 +00:00
|
|
|
# Hack
|
|
|
|
sys.argv.append('--gst-debug-no-color')
|
|
|
|
|
2004-04-16 13:56:39 +00:00
|
|
|
path = os.path.abspath(os.path.join('..', 'gst'))
|
|
|
|
import gst
|
2004-05-01 15:35:32 +00:00
|
|
|
assert gst._gst.__file__ == '../gst/_gst.la'
|
2004-03-17 12:41:08 +00:00
|
|
|
|
|
|
|
try:
|
2004-04-16 13:56:39 +00:00
|
|
|
import gst.interfaces
|
|
|
|
assert os.path.basename(gst.interfaces.__file__) != path, 'bad path'
|
2004-03-17 12:41:08 +00:00
|
|
|
except ImportError:
|
2004-04-16 13:56:39 +00:00
|
|
|
pass
|
2004-03-17 12:41:08 +00:00
|
|
|
|
|
|
|
try:
|
2004-04-16 13:56:39 +00:00
|
|
|
import gst.play
|
|
|
|
assert os.path.basename(gst.play.__file__) != path, 'bad path'
|
2004-03-17 12:41:08 +00:00
|
|
|
except ImportError:
|
2004-04-16 13:56:39 +00:00
|
|
|
pass
|
2004-03-17 12:41:08 +00:00
|
|
|
|
2004-05-01 15:35:32 +00:00
|
|
|
_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
|
2004-05-03 16:17:38 +00:00
|
|
|
|
|
|
|
def run_silent(function, *args, **kwargs):
|
|
|
|
disable_stderr()
|
|
|
|
|
|
|
|
try:
|
|
|
|
function(*args, **kwargs)
|
|
|
|
except Exception, exc:
|
|
|
|
enable_stderr()
|
|
|
|
raise exc
|
|
|
|
|
|
|
|
output = enable_stderr()
|
|
|
|
|
|
|
|
return output
|