[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [stem/master] Add missing assertItemsEqual() for python 2.6



commit c7767632e340f94052c6cfd5c2c49b02afb8ea99
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Thu Dec 31 09:28:38 2015 -0800

    Add missing assertItemsEqual() for python 2.6
    
    Ok, that does it. Rather than avoiding use of methods on python 2.6 gonna add
    them when simple to do so. Since our last release we've started using
    assertItemsEqual. This wasn't available back then so adding it.
    
      ======================================================================
      ERROR: test_votes_by_bandwidth_authorities
      ----------------------------------------------------------------------
      Traceback (most recent call last):
        File "/usr/local/lib/python2.6/dist-packages/mock.py", line 1201, in patched
          return func(*args, **keywargs)
        File "/home/atagar/Desktop/stem/test/unit/tutorial_examples.py", line 311, in test_votes_by_bandwidth_authorities
          self.assert_equal_unordered(VOTES_BY_BANDWIDTH_AUTHORITIES_OUTPUT, stdout_mock.getvalue())
        File "/home/atagar/Desktop/stem/test/unit/tutorial_examples.py", line 141, in assert_equal_unordered
          self.assertItemsEqual(expected.splitlines(), actual.splitlines())
      AttributeError: 'TestTutorialExamples' object has no attribute 'assertItemsEqual'
    
      ----------------------------------------------------------------------
      Ran 6 tests in 0.255s
---
 run_tests.py |    6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/run_tests.py b/run_tests.py
index cbd01f0..fa56580 100755
--- a/run_tests.py
+++ b/run_tests.py
@@ -86,6 +86,12 @@ PEP8_TASK = Task(
   print_result = False,
 )
 
+if (2, 6) == sys.version_info[0:2]:
+  def assertItemsEqual(self, expected, actual):
+    self.assertEqual(set(expected), set(actual))
+
+  unittest.TestCase.assertItemsEqual = assertItemsEqual
+
 
 def main():
   start_time = time.time()



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits