[gnumeric] Introspection: add test to ensure we use in-tree Gnm.py overrides
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Introspection: add test to ensure we use in-tree Gnm.py overrides
- Date: Fri, 27 Apr 2018 12:44:09 +0000 (UTC)
commit b860ec231f019a411f8e1be1c4346d559f2ee10d
Author: Morten Welinder <terra gnome org>
Date: Fri Apr 27 08:42:58 2018 -0400
Introspection: add test to ensure we use in-tree Gnm.py overrides
I.e., make sure we test the right code.
introspection/gi/overrides/Gnm.py | 6 +++++-
test/Makefile.am | 3 ++-
test/t3004-introspection-overrides.pl | 13 +++++++++++++
test/t3004-introspection-overrides.py | 33 +++++++++++++++++++++++++++++++++
4 files changed, 53 insertions(+), 2 deletions(-)
---
diff --git a/introspection/gi/overrides/Gnm.py b/introspection/gi/overrides/Gnm.py
index b7f164e..926d1a5 100644
--- a/introspection/gi/overrides/Gnm.py
+++ b/introspection/gi/overrides/Gnm.py
@@ -33,7 +33,11 @@ Gnm.ValueType.__str__ = _valuetype_str
class Value(Gnm.Value):
def __str__(self):
- return self.type_of().value_name + ":" + self.get_as_string()
+ fmt = self.v_any.fmt
+ main = self.type_of().value_name + "," + self.get_as_string()
+ if fmt is not None:
+ main += "," + str(fmt)
+ return "{" + main + "}";
Value = override(Value)
__all__.append('Value')
diff --git a/test/Makefile.am b/test/Makefile.am
index 458c05f..a30ee5d 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -184,7 +184,8 @@ INTROSPECTION_TSTS = \
t3000-introspection-basic.pl \
t3001-introspection-simple.pl \
t3002-introspection-io.pl \
- t3003-introspection-plugins.pl
+ t3003-introspection-plugins.pl \
+ t3004-introspection-overrides.pl
INTROSPECTION_SUPPS = \
$(INTROSPECTION_TSTS:.pl=.py)
diff --git a/test/t3004-introspection-overrides.pl b/test/t3004-introspection-overrides.pl
new file mode 100755
index 0000000..fdaf1de
--- /dev/null
+++ b/test/t3004-introspection-overrides.pl
@@ -0,0 +1,13 @@
+#!/usr/bin/perl -w
+# -----------------------------------------------------------------------------
+
+use strict;
+use lib ($0 =~ m|^(.*/)| ? $1 : ".");
+use GnumericTest;
+
+&setup_python_environment ();
+
+my $python_script = $0;
+$python_script =~ s/\.pl$/.py/;
+&test_command ($PYTHON . ' ' . &GnumericTest::quotearg ($python_script),
+ sub { /^Using in-tree / });
diff --git a/test/t3004-introspection-overrides.py b/test/t3004-introspection-overrides.py
new file mode 100755
index 0000000..477d69d
--- /dev/null
+++ b/test/t3004-introspection-overrides.py
@@ -0,0 +1,33 @@
+#!/usr/bin/python
+# -----------------------------------------------------------------------------
+
+import gi
+gi.require_version('Gnm', '1.12')
+from gi.repository import Gnm
+Gnm.init()
+
+import os.path;
+
+def atomize_path(p):
+ res=[]
+ while 1:
+ h,t = os.path.split(p)
+ if t != "":
+ res.append(t)
+ if h == "":
+ break
+ if h == p:
+ res.append(h)
+ break;
+ p = h
+ res.reverse()
+ return res
+
+l=atomize_path(os.path.dirname(gi.overrides.Gnm.__file__))
+if len(l) > 3 and l[-3] == "introspection":
+ print("Using in-tree gi.overrides.Gnm")
+else:
+ print("Using installed gi.overrides.Gnm at {}"
+ .format (gi.overrides.Gnm.__file__))
+
+print Gnm.Value.new_int(12)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]