diff 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
line wrap: on
line diff
--- a/src/test/helpers.py	Fri Jan 10 21:12:06 2014 +0100
+++ b/src/test/helpers.py	Tue Jan 07 09:27:53 2014 +0100
@@ -28,6 +28,7 @@
 from twisted.internet import defer
 from twisted.words.protocols.jabber.jid import JID
 from xml.etree import cElementTree as etree
+from collections import Counter
 import re
 
 
@@ -48,6 +49,10 @@
     pass
 
 
+class DifferentListException(FailTest):
+    pass
+
+
 class FakeSAT(object):
     """Class to simulate a SAT instance"""
 
@@ -292,3 +297,16 @@
             print "was expecting:\n-\n%s\n-\n\n" % etree.tostring(expected_elt, encoding='utf-8')
             print "---"
             raise DifferentXMLException
+
+    def assertEqualUnsortedList(self, a, b, msg):
+        counter_a = Counter(a)
+        counter_b = Counter(b)
+        if counter_a != counter_b:
+            print "---"
+            print "Unsorted lists are not equals:"
+            print "got          : %s" % counter_a
+            print "was expecting: %s" % counter_b
+            if msg:
+                print msg
+            print "---"
+            raise DifferentListException