summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSimon McVittie <smcv@debian.org>2016-03-06 17:52:44 +0000
committerSimon McVittie <smcv@debian.org>2016-03-06 17:52:44 +0000
commit8b5552ac4697114cdadad2d4c0cda8c4def777ce (patch)
tree02ef0fbafd8dd0bbf7904677a2664b7041a95db2 /test
parent7c1f8911089c209335aa90c445fd6aeed116ca54 (diff)
Imported Upstream version 1.2.4
Diffstat (limited to 'test')
-rw-r--r--test/dbus_py_test.c2
-rwxr-xr-xtest/run-test.sh5
-rwxr-xr-xtest/test-standalone.py56
3 files changed, 50 insertions, 13 deletions
diff --git a/test/dbus_py_test.c b/test/dbus_py_test.c
index ea892ab..bd2399d 100644
--- a/test/dbus_py_test.c
+++ b/test/dbus_py_test.c
@@ -24,7 +24,7 @@
*/
#include <Python.h>
-#include "dbus-python.h"
+#include <dbus/dbus-python.h>
#ifdef PY3
PyMODINIT_FUNC PyInit_dbus_py_test(void);
diff --git a/test/run-test.sh b/test/run-test.sh
index 9eacd1a..ae370a4 100755
--- a/test/run-test.sh
+++ b/test/run-test.sh
@@ -68,10 +68,11 @@ cross_test_server_pid="$!"
$PYTHON "$DBUS_TOP_SRCDIR"/test/wait-for-name.py org.freedesktop.DBus.Binding.TestServer
+e=0
$PYTHON "$DBUS_TOP_SRCDIR"/test/cross-test-client.py > "$DBUS_TEST_TMPDIR"/cross-client.log || e=$?
echo "test-client exit status: $e"
-if test $e = 77; then
+if test "$e" = 77; then
echo "cross-test-client exited $e, marking as skipped"
skipped=yes
elif grep . "$DBUS_TEST_TMPDIR"/cross-client.log >/dev/null; then
@@ -81,7 +82,7 @@ else
failed=yes
fi
-if test $e = 77; then
+if test "$e" = 77; then
echo "test-client exited $e, marking as skipped"
skipped=yes
elif grep . "$DBUS_TEST_TMPDIR"/cross-server.log >/dev/null; then
diff --git a/test/test-standalone.py b/test/test-standalone.py
index 6a68c36..ea1e894 100755
--- a/test/test-standalone.py
+++ b/test/test-standalone.py
@@ -28,6 +28,7 @@ run in isolation.
from __future__ import unicode_literals
+import struct
import sys
import os
import unittest
@@ -69,6 +70,36 @@ assert (_dbus_bindings._python_version & 0xffff0000
'a different major version'\
% (_dbus_bindings._python_version, sys.hexversion)
+def uni(x):
+ """Return a Unicode string consisting of the single Unicode character
+ with the given codepoint (represented as a surrogate pair if this is
+ a "narrow" Python build). This is a generalization of unichr().
+
+ uni(0x0001f639) == u'\\U0001f639' in versions where that syntax is
+ supported.
+ """
+ if x <= 0xFFFF:
+ if is_py3:
+ return chr(x)
+ else:
+ return unichr(x)
+ elif is_py3:
+ return struct.pack('>I', x).decode('utf_32_be')
+ else:
+ # Python 2.6 didn't accept unicode format strings
+ return struct.pack(b'>I', x).decode('utf_32_be')
+
+def utf8(*xs):
+ """Return a bytestring containing the given UTF-8 bytes.
+
+ utf8(0xc2, 0xa3) == b'\\xc2\\xa3' on Python versions that
+ allow bytestring literals (but some Python 2 versions do not).
+ """
+ if is_py3:
+ return bytes(xs)
+ else:
+ return str('').join(map(chr, xs))
+
class TestTypes(unittest.TestCase):
def test_Dictionary(self):
@@ -430,16 +461,7 @@ class TestMessageMarshalling(unittest.TestCase):
def test_utf8(self):
from _dbus_bindings import SignalMessage
- if is_py3:
- def utf8(*xs):
- return bytes(xs)
- def uni(x):
- return chr(x)
- else:
- def utf8(*xs):
- return str('').join(map(chr, xs))
- def uni(x):
- return unichr(x)
+
for bad in [
uni(0xD800),
utf8(0xed, 0xa0, 0x80),
@@ -514,6 +536,20 @@ class TestMatching(unittest.TestCase):
self._message.append('/', signature='o')
self.assertFalse(self._match.maybe_handle_message(self._message))
+class TestVersion(unittest.TestCase):
+ if sys.version_info[:2] < (2, 7):
+ def assertGreater(self, first, second):
+ self.assertTrue(first > second)
+
+ def assertLess(self, first, second):
+ self.assertTrue(first < second)
+
+ def test_version(self):
+ self.assertGreater(dbus.version, (0, 41))
+ self.assertLess(dbus.version, (23, 0))
+ self.assertGreater(dbus.__version__, '0')
+ self.assertLess(dbus.__version__, '9')
+
if __name__ == '__main__':
# Python 2.6 doesn't accept a `verbosity` keyword.
kwargs = {}