Closed deagon closed 4 years ago
This test case is always failed on my develop environment, namely OSX(Mojave-10.14.2)-python3.7. IMO, use another way is more compatibility.
Can you please write a more comprehensive explanation? I didn't fully understand.
I got this output before.
# tox -e py37
GLOB sdist-make: /Users/deagon/GithubProjects/PySnooper/setup.py
py37 inst-nodeps: /Users/deagon/GithubProjects/PySnooper/.tox/dist/PySnooper-0.2.5.zip
py37 installed: atomicwrites==1.3.0,attrs==19.1.0,importlib-metadata==0.20,more-itertools==7.2.0,packaging==19.1,pluggy==0.12.0,py==1.8.0,pyparsing==2.4.2,PySnooper==0.2.5,pytest==5.1.2,six==1.12.0,wcwidth==0.1.7,zipp==0.6.0
py37 runtests: PYTHONHASHSEED='2319826058'
py37 runtests: commands[0] | pytest
=================================================================================================== test session starts ====================================================================================================
platform darwin -- Python 3.7.4, pytest-5.1.2, py-1.8.0, pluggy-0.12.0
rootdir: /Users/deagon/GithubProjects/PySnooper, inifile: tox.ini
collected 34 items
tests/test_chinese.py . [ 2%]
tests/test_pysnooper.py ..F............................ [ 94%]
tests/test_multiple_files/test_multiple_files.py . [ 97%]
tests/test_utils/test_ensure_tuple.py . [100%]
========================================================================================================= FAILURES =========================================================================================================
__________________________________________________________________________________________________ test_multi_thread_info __________________________________________________________________________________________________
def test_multi_thread_info():
@pysnooper.snoop(thread_info=True)
def my_function(foo):
x = 7
y = 8
return y + x
with mini_toolbox.OutputCapturer(stdout=False,
stderr=True) as output_capturer:
my_function('baba')
t1 = threading.Thread(target=my_function, name="test123",args=['bubu'])
t1.start()
t1.join()
t1 = threading.Thread(target=my_function, name="bibi",args=['bibi'])
t1.start()
t1.join()
output = output_capturer.string_io.getvalue()
calls = [line for line in output.split("\n") if "call" in line]
main_thread = calls[0]
> assert len(main_thread) == len(calls[1])
E AssertionError: assert 78 == 80
E + where 78 = len('20:04:19.295432 4597577152-MainThread call 84 def my_function(foo):')
E + and 80 = len('20:04:19.295797 123145506770944-test123 call 84 def my_function(foo):')
tests/test_pysnooper.py:101: AssertionError
=============================================================================================== 1 failed, 33 passed in 0.30s ===============================================================================================
ERROR: InvocationError: '/Users/deagon/GithubProjects/PySnooper/.tox/py37/bin/pytest'
_________________________________________________________________________________________________________ summary __________________________________________________________________________________________________________
ERROR: py37: commands failed
I'm not sure how it works, and I think the code for that test is pretty opaque (both before and after your changes,) but I've merged it and I hope this code would just work and I won't have to look at it again :)
The length of thread's ident between "MainThread" and others are not always equal. So use another way to check it.