diff options
author | David Malcolm <dmalcolm@redhat.com> | 2010-04-20 14:57:57 -0400 |
---|---|---|
committer | David Malcolm <dmalcolm@redhat.com> | 2010-04-20 14:57:57 -0400 |
commit | 0d014eca13009777850d279fb98a6820a76fc9e5 (patch) | |
tree | 4c6bd59436e278335e91566e95131bd0f6011adf | |
parent | dedf0c380d1fa551ce9d7fd544b9973202ba1b05 (diff) | |
download | pygi-0d014eca13009777850d279fb98a6820a76fc9e5.tar.gz pygi-0d014eca13009777850d279fb98a6820a76fc9e5.tar.xz pygi-0d014eca13009777850d279fb98a6820a76fc9e5.zip |
Generalize CONSTANT_UTF8 to be a UTF-8 encoded bytes in Python 2 and a unicode string in Python 3
-rw-r--r-- | tests/test_gi.py | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/tests/test_gi.py b/tests/test_gi.py index 200c15c..41a12e2 100644 --- a/tests/test_gi.py +++ b/tests/test_gi.py @@ -14,8 +14,30 @@ sys.path.insert(0, "../") from gi.repository import GIMarshallingTests +# CONSTANT_UTF8 is a constant value from inside GIMarshallingTests, containing +# bytes representing a UTF-8 encoded string. +# +# We will try and invoke entry points in GIMarshallingTests, passing a string. +# The entry points assert that the string they receive is the same value, thus +# verifying that marshalling of string values is working. +# +# The string is defined in gobject-introspection/gir/gimarshallingtests.h +# where it has value "const \xe2\x99\xa5 utf8" +# i.e. +# "const " + U+2665 BLACK HEART SUIT + " utf8" +# as U+2665 BLACK HEART SUIT: 0xE2 0x99 0xA5 in UTF8 +# +try: + _u = unicode + + # For Python 2, we express it as a UTF8-encoded string literal: + CONSTANT_UTF8 = "const \xe2\x99\xa5 utf8" + +except NameError: + # For Python 3, we express it as a (unicode) string: + CONSTANT_UTF8 = "const " + chr(0x2665) + " utf8" + -CONSTANT_UTF8 = "const \xe2\x99\xa5 utf8" CONSTANT_NUMBER = 42 |