[tor-commits] [stem/master] Fix test_close_stream assertion

atagar at torproject.org atagar at torproject.org
Sun Jun 2 18:42:49 UTC 2019


commit e5aba03229f163ba73e88a20f0da277fad1c368a
Author: Damian Johnson <atagar at torproject.org>
Date:   Sun Jun 2 10:53:53 2019 -0700

    Fix test_close_stream assertion
    
    When running our online target we might have multiple streams in process.
    Fixing our assertion so we check if the stream we expect is present rather
    than the only one.
    
      https://trac.torproject.org/projects/tor/ticket/30696
    
      ======================================================================
      FAIL: test_close_stream
      ----------------------------------------------------------------------
      Traceback (most recent call last):
        File "/home/atagar/Desktop/stem/test/require.py", line 57, in wrapped
          return func(self, *args, **kwargs)
        File "/home/atagar/Desktop/stem/test/require.py", line 57, in wrapped
          return func(self, *args, **kwargs)
        File "/home/atagar/Desktop/stem/test/integ/control/controller.py", line 1072, in test_close_stream
          self.assertEqual([built_stream.id], [stream.id for stream in controller.get_streams()])
      AssertionError: Lists differ: ['48'] != ['48', '58', '473']
    
      Second list contains 2 additional elements.
      First extra element 1:
      '58'
    
      - ['48']
      + ['48', '58', '473']
---
 test/integ/control/controller.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/test/integ/control/controller.py b/test/integ/control/controller.py
index fd4c81dc..ef90de80 100644
--- a/test/integ/control/controller.py
+++ b/test/integ/control/controller.py
@@ -1069,15 +1069,15 @@ class TestController(unittest.TestCase):
         # Make sure we have the stream for which we asked, otherwise
         # the next assertion would be a false positive.
 
-        self.assertEqual([built_stream.id], [stream.id for stream in controller.get_streams()])
+        self.assertTrue(built_stream.id in [stream.id for stream in controller.get_streams()])
 
         # Try to close our stream...
 
         controller.close_stream(built_stream.id)
 
-        # ...which means there are zero streams.
+        # ... after which the stream should no longer be present.
 
-        self.assertEqual([], controller.get_streams())
+        self.assertFalse(built_stream.id in [stream.id for stream in controller.get_streams()])
 
       # unknown stream
 





More information about the tor-commits mailing list