[pygobject] GObject.Value: a bit more test coverage
- From: Christoph Reiter <creiter src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] GObject.Value: a bit more test coverage
- Date: Fri, 18 Jan 2019 19:29:36 +0000 (UTC)
commit 7fcc843c41460451200d2dcc065d446f81f4dbd9
Author: Christoph Reiter <reiter christoph gmail com>
Date: Fri Jan 18 19:20:09 2019 +0100
GObject.Value: a bit more test coverage
tests/test_overrides_gobject.py | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
---
diff --git a/tests/test_overrides_gobject.py b/tests/test_overrides_gobject.py
index 56a62f13..5c157f0e 100644
--- a/tests/test_overrides_gobject.py
+++ b/tests/test_overrides_gobject.py
@@ -72,6 +72,12 @@ def test_value_invalid_type():
with pytest.raises(ValueError, match="Invalid GType"):
v.init(GObject.TYPE_INVALID)
+ with pytest.raises(
+ TypeError, match="GObject.Value needs to be initialized first"):
+ v.set_value(None)
+
+ assert v.get_value() is None
+
def test_value_long():
v = GObject.Value(GObject.TYPE_LONG)
@@ -274,3 +280,23 @@ def test_value_set_boxed_deprecate_non_boxed():
v.get_boxed()
with pytest.warns(PyGIDeprecationWarning):
v.set_boxed(None)
+
+
+def test_value_boolean():
+ v = GObject.Value(GObject.TYPE_BOOLEAN)
+ assert v.get_value() is False
+ assert isinstance(v.get_value(), bool)
+
+ v.set_value(42)
+ assert v.get_value() is True
+ v.set_value(-1)
+ assert v.get_value() is True
+ v.set_value(0)
+ assert v.get_value() is False
+
+ v.set_value([])
+ assert v.get_value() is False
+ v.set_value(["foo"])
+ assert v.get_value() is True
+ with pytest.raises(TypeError):
+ v.set_value(None)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]