comparison src/test/helpers.py @ 789:0cb423500fbb

test: use the SatTestCase methods instead of builtin "assert" in tests for memory, plugin xep-0033
author souliane <souliane@mailoo.org>
date Tue, 07 Jan 2014 09:27:53 +0100
parents c3acc1298a2f
children 2136be5a44a8
comparison
equal deleted inserted replaced
788:d6652683c572 789:0cb423500fbb
26 from twisted.trial.unittest import FailTest 26 from twisted.trial.unittest import FailTest
27 from twisted.trial import unittest 27 from twisted.trial import unittest
28 from twisted.internet import defer 28 from twisted.internet import defer
29 from twisted.words.protocols.jabber.jid import JID 29 from twisted.words.protocols.jabber.jid import JID
30 from xml.etree import cElementTree as etree 30 from xml.etree import cElementTree as etree
31 from collections import Counter
31 import re 32 import re
32 33
33 34
34 def b2s(value): 35 def b2s(value):
35 """Convert a bool to a unicode string used in bridge 36 """Convert a bool to a unicode string used in bridge
43 class DifferentArgsException(FailTest): 44 class DifferentArgsException(FailTest):
44 pass 45 pass
45 46
46 47
47 class DifferentXMLException(FailTest): 48 class DifferentXMLException(FailTest):
49 pass
50
51
52 class DifferentListException(FailTest):
48 pass 53 pass
49 54
50 55
51 class FakeSAT(object): 56 class FakeSAT(object):
52 """Class to simulate a SAT instance""" 57 """Class to simulate a SAT instance"""
290 print "XML are not equals:" 295 print "XML are not equals:"
291 print "got:\n-\n%s\n-\n\n" % etree.tostring(xml_elt, encoding='utf-8') 296 print "got:\n-\n%s\n-\n\n" % etree.tostring(xml_elt, encoding='utf-8')
292 print "was expecting:\n-\n%s\n-\n\n" % etree.tostring(expected_elt, encoding='utf-8') 297 print "was expecting:\n-\n%s\n-\n\n" % etree.tostring(expected_elt, encoding='utf-8')
293 print "---" 298 print "---"
294 raise DifferentXMLException 299 raise DifferentXMLException
300
301 def assertEqualUnsortedList(self, a, b, msg):
302 counter_a = Counter(a)
303 counter_b = Counter(b)
304 if counter_a != counter_b:
305 print "---"
306 print "Unsorted lists are not equals:"
307 print "got : %s" % counter_a
308 print "was expecting: %s" % counter_b
309 if msg:
310 print msg
311 print "---"
312 raise DifferentListException