mike820324 / microProxy

A http/https interceptor written in pure python.
MIT License
17 stars 3 forks source link

[UnitTest]: test_iostream.py failed on my OSX #211

Closed chhsiao90 closed 7 years ago

chhsiao90 commented 7 years ago

When I try run unit test with python -m unittest discover It always failed the unit test

ERROR: test_close_buffered_data (microproxy.test.tornado_ext.test_iostream.TestIOStream)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/han-pc/.pyenv/versions/mp/lib/python2.7/site-packages/tornado/testing.py", line 132, in __call__
    result = self.orig_method(*args, **kwargs)
  File "/Users/han-pc/workspace/python/microProxy/microproxy/test/tornado_ext/test_iostream.py", line 315, in test_close_buffered_data
    client.read_bytes(256, self.stop)
  File "/Users/han-pc/.pyenv/versions/mp/lib/python2.7/site-packages/tornado/iostream.py", line 317, in read_bytes
    self._try_inline_read()
  File "/Users/han-pc/.pyenv/versions/mp/lib/python2.7/site-packages/tornado/iostream.py", line 701, in _try_inline_read
    self._check_closed()
  File "/Users/han-pc/.pyenv/versions/mp/lib/python2.7/site-packages/tornado/iostream.py", line 885, in _check_closed
    raise StreamClosedError(real_error=self.error)
StreamClosedError: Stream is closed

----------------------------------------------------------------------

But when I only run test_iostream.py python -m unittest discover -p test_iostream.py The test would pass.

It seems some problem caused by iostream.py

if events & self.io_loop.READ:
        # NOTE: We use explict read instead of implicit.
        # The reason IOStream is not idle is that when an event happened,
        # tornado iostream will still try to read them into buffer.
        # Our approach is that when someone is trying to read the iostream,
        # we will read it.
         if self._should_socket_close() or self.reading():
             self._handle_read()

I know the modification is for the iostream not idle problem, but do you have any idea that I could pass the unit test?

mike820324 commented 7 years ago

It seems like the regression only occur in osx. I'll test in my linux machine later.

This is something that I'll need to dig more further. Thanks for reporting this.

chhsiao90 commented 7 years ago

I found that the unit test failed only when running test including microproxy/test/event/test_replay.py That's mean the test will pass if I removed microproxy/test/event/test_replay.py So I will find where the problem is at the test...

mike820324 commented 7 years ago

Wow, this behaviro is pretty weird. thanks