summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThibault Saunier <tsaunier@gnome.org>2015-04-24 10:35:14 +0200
committerThibault Saunier <tsaunier@gnome.org>2015-04-24 11:25:38 +0200
commited1f9eccba0ee0fd5aad6cb679c9aaf39148b474 (patch)
tree4368d9e3eab8980caa39d41e4744f4b098ccc901
parentb80ea319cd414123d911a8a3a3e840d1ca6e3927 (diff)
tests: Fix tests in python2
Python2 core checks that the first argument of a method is of the type of the object if it does not have any info about the method, so when using Gst not initialized it raiser a TypeError and not a Gst.NotInitialized as expected. + And fix a typo
-rw-r--r--gi/overrides/Gst.py6
-rw-r--r--testsuite/overrides_hack.py7
-rw-r--r--testsuite/test_gst.py23
3 files changed, 26 insertions, 10 deletions
diff --git a/gi/overrides/Gst.py b/gi/overrides/Gst.py
index 9abfbcf..f306fc5 100644
--- a/gi/overrides/Gst.py
+++ b/gi/overrides/Gst.py
@@ -338,12 +338,12 @@ Gst.fixme = _gi_gst.fixme
Gst.memdump = _gi_gst.memdump
# Make sure PyGst is not usable if GStreamer has not been initialized
-class NotInitalized(Exception):
+class NotInitialized(Exception):
pass
-__all__.append('NotInitalized')
+__all__.append('NotInitialized')
def fake_method(*args):
- raise NotInitalized("Please call Gst.init(argv) before using GStreamer")
+ raise NotInitialized("Please call Gst.init(argv) before using GStreamer")
real_functions = [o for o in inspect.getmembers(Gst) if isinstance(o[1], type(Gst.init))]
diff --git a/testsuite/overrides_hack.py b/testsuite/overrides_hack.py
index 7aae046..f8e15ce 100644
--- a/testsuite/overrides_hack.py
+++ b/testsuite/overrides_hack.py
@@ -1,3 +1,4 @@
+import os
import gi.overrides
if not gi.overrides.__path__[0].endswith("gst-python/gi/overrides"):
@@ -7,5 +8,9 @@ if not gi.overrides.__path__[0].endswith("gst-python/gi/overrides"):
if path.endswith("gst-python/gi/overrides"):
local_overrides = path
- gi.overrides.__path__.remove(local_overrides)
+ if local_overrides:
+ gi.overrides.__path__.remove(local_overrides)
+ else:
+ local_overrides = os.path.abspath(os.path.join(__file__, "../", "../", "gi", "overrides"))
+
gi.overrides.__path__.insert(0, local_overrides)
diff --git a/testsuite/test_gst.py b/testsuite/test_gst.py
index 637c902..e04b38f 100644
--- a/testsuite/test_gst.py
+++ b/testsuite/test_gst.py
@@ -17,6 +17,7 @@
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+import sys
import overrides_hack
overrides_hack
from common import TestCase, unittest
@@ -38,13 +39,18 @@ class TimeArgsTest(TestCase):
class TestNotInitialized(TestCase):
def testNotInitialized(self):
- with self.assertRaises(Gst.NotInitalized):
+ if sys.version_info >= (3, 0):
+ assert_type = Gst.NotInitialized
+ else:
+ assert_type = TypeError
+
+ with self.assertRaises(assert_type):
Gst.Caps.from_string("audio/x-raw")
- with self.assertRaises(Gst.NotInitalized):
+ with self.assertRaises(assert_type):
Gst.Structure.from_string("audio/x-raw")
- with self.assertRaises(Gst.NotInitalized):
+ with self.assertRaises(assert_type):
Gst.ElementFactory.make("identity", None)
def testNotDeinitialized(self):
@@ -55,13 +61,18 @@ class TestNotInitialized(TestCase):
assert(Gst.ElementFactory.make("identity", None))
Gst.deinit()
- with self.assertRaises(Gst.NotInitalized):
+ if sys.version_info >= (3, 0):
+ assert_type = Gst.NotInitialized
+ else:
+ assert_type = TypeError
+
+ with self.assertRaises(assert_type):
Gst.Caps.from_string("audio/x-raw")
- with self.assertRaises(Gst.NotInitalized):
+ with self.assertRaises(assert_type):
Gst.Structure.from_string("audio/x-raw")
- with self.assertRaises(Gst.NotInitalized):
+ with self.assertRaises(assert_type):
Gst.ElementFactory.make("identity", None)