~barry/ubuntu/quantal/dbus-python/lp846044

« back to all changes in this revision

Viewing changes to test/test-standalone.py

  • Committer: Package Import Robot
  • Author(s): Simon McVittie
  • Date: 2012-06-25 17:35:50 UTC
  • mfrom: (1.2.3)
  • mto: This revision was merged to the branch mainline in revision 40.
  • Revision ID: package-import@ubuntu.com-20120625173550-x9zz8axwd82d7jma
* New upstream version
  - fixes type-signature guessing when an ObjectPath is given (LP: #1008898)
* Increase dbus build-dependency to the recommended version, 1.6
* Include /usr/share/dpkg/default.mk for recommended build flags

Show diffs side-by-side

added added

removed removed

Lines of Context:
322
322
        aeq(Message.guess_signature(('a',)), '(s)')
323
323
        aeq(Message.guess_signature(['a']), 'as')
324
324
        aeq(Message.guess_signature({'a':'b'}), 'a{ss}')
 
325
        aeq(Message.guess_signature(types.ObjectPath('/')), 'o')
 
326
        aeq(Message.guess_signature(types.Signature('x')), 'g')
325
327
 
326
328
    def test_guess_signature_python_ints(self):
327
329
        aeq = self.assertEqual
421
423
            raise AssertionError('Appending too many things in a struct '
422
424
                                 'should fail')
423
425
 
 
426
    def test_utf8(self):
 
427
        from _dbus_bindings import SignalMessage
 
428
        if is_py3:
 
429
            def utf8(*xs):
 
430
                return bytes(xs)
 
431
            def uni(x):
 
432
                return chr(x)
 
433
        else:
 
434
            def utf8(*xs):
 
435
                return str('').join(map(chr, xs))
 
436
            def uni(x):
 
437
                return unichr(x)
 
438
        for bad in [
 
439
                uni(0xD800),
 
440
                utf8(0xed, 0xa0, 0x80),
 
441
                uni(0xFDD0),
 
442
                utf8(0xef, 0xb7, 0x90),
 
443
                uni(0xFDD7),
 
444
                utf8(0xef, 0xb7, 0x97),
 
445
                uni(0xFDEF),
 
446
                utf8(0xef, 0xb7, 0xaf),
 
447
                uni(0xFFFE),
 
448
                utf8(0xef, 0xbf, 0xbe),
 
449
                uni(0xFFFF),
 
450
                utf8(0xef, 0xbf, 0xbf),
 
451
                uni(0x0001FFFE),
 
452
                utf8(0xf0, 0x9f, 0xbf, 0xbe),
 
453
                uni(0x0001FFFF),
 
454
                utf8(0xf0, 0x9f, 0xbf, 0xbf),
 
455
                uni(0x0007FFFE),
 
456
                utf8(0xf1, 0xbf, 0xbf, 0xbe),
 
457
                uni(0x0007FFFF),
 
458
                utf8(0xf1, 0xbf, 0xbf, 0xbf),
 
459
                uni(0x0010FFFE),
 
460
                utf8(0xf4, 0x8f, 0xbf, 0xbe),
 
461
                uni(0x0010FFFF),
 
462
                utf8(0xf4, 0x8f, 0xbf, 0xbf),
 
463
                ]:
 
464
            s = SignalMessage('/', 'foo.bar', 'baz')
 
465
            try:
 
466
                s.append(bad, signature='s')
 
467
            except UnicodeError:
 
468
                pass
 
469
            else:
 
470
                raise AssertionError('Appending %r should fail' % bad)
 
471
        for good in [
 
472
                uni(0xfdcf),
 
473
                uni(0xfdf0),
 
474
                uni(0xfeff),
 
475
                uni(0x0001feff),
 
476
                uni(0x00020000),
 
477
                uni(0x0007feff),
 
478
                uni(0x00080000),
 
479
                uni(0x0010feff),
 
480
                ]:
 
481
            s = SignalMessage('/', 'foo.bar', 'baz')
 
482
            s.append(good, signature='s')
 
483
            s.append(good.encode('utf-8'), signature='s')
424
484
 
425
485
class TestMatching(unittest.TestCase):
426
486
    def setUp(self):
440
500
        self._message.append('/', signature='o')
441
501
        self.assertFalse(self._match.maybe_handle_message(self._message))
442
502
 
443
 
 
444
503
if __name__ == '__main__':
445
504
    # Python 2.6 doesn't accept a `verbosity` keyword.
446
505
    kwargs = {}