def test_Signature(self): self.assertRaises(Exception, types.Signature, 'a') self.assertEqual(types.Signature('ab', variant_level=23), 'ab') self.assertTrue(isinstance(types.Signature('ab'), str)) self.assertEqual(tuple(types.Signature('ab(xt)a{sv}')), ('ab', '(xt)', 'a{sv}')) self.assertTrue(isinstance(tuple(types.Signature('ab'))[0], types.Signature))
def test_Signature(self): self.assertRaises(Exception, types.Signature, 'a') self.assertEqual(types.Signature('ab', variant_level=23), 'ab') self.assertTrue(isinstance(types.Signature('ab'), str)) self.assertEqual(tuple(types.Signature('ab(xt)a{sv}')), ('ab', '(xt)', 'a{sv}')) self.assertTrue(isinstance(tuple(types.Signature('ab'))[0], types.Signature)) self.assertEqual(str(types.Signature('ab')), 'ab') self.assertIs(type(str(types.Signature('ab'))), str) if is_py2: self.assertEqual(str(types.Signature('ab')), 'ab') self.assertIs(type(str(types.Signature('ab'))), str) self.assertEqual(unicode(types.Signature('ab')), 'ab'.decode('ascii')) self.assertIs(type(unicode(types.Signature('ab'))), unicode)
def test_guess_signature(self): aeq = self.assertEqual from _dbus_bindings import Message aeq(Message.guess_signature(('a','b')), '(ss)') aeq(Message.guess_signature('a','b'), 'ss') aeq(Message.guess_signature(['a','b']), 'as') aeq(Message.guess_signature(('a',)), '(s)') aeq(Message.guess_signature('abc'), 's') aeq(Message.guess_signature(types.Int32(123)), 'i') aeq(Message.guess_signature(types.ByteArray(b'abc')), 'ay') aeq(Message.guess_signature(('a',)), '(s)') aeq(Message.guess_signature(['a']), 'as') aeq(Message.guess_signature({'a':'b'}), 'a{ss}') aeq(Message.guess_signature(types.ObjectPath('/')), 'o') aeq(Message.guess_signature(types.Signature('x')), 'g')