toolbelt icon indicating copy to clipboard operation
toolbelt copied to clipboard

Test failures with current releases of requests

Open dol-sen opened this issue 6 years ago • 0 comments

I am getting test failures for python-2.7. Tests are passing with python 3.4, 3.5, 3.6.

These failures are occuring in the 0.7.1 release as well, probably even older releases.

PLEASE update .travis.yml to include testing against newer releases of the requests package. The releases you are testing against are more than 4 years old now.

2.2.0 (2014-01-09) 2.1.0 (2013-12-05)

The current releases: 2.18.4 (2017-08-15) 2.18.3 (2017-08-02)

Are quickly approaching 1 year old already. and the oldest release still available in Gentoo now is: requests-2.11.1.

The following is the result against requests-2.18.2

bdolbec@gk7138 ~/git/toolbelt $ pytest -vv
=============================================================================== test session starts ===============================================================================
platform linux2 -- Python 2.7.14, pytest-3.0.3, py-1.4.30, pluggy-0.4.0 -- /usr/bin/python2.7
cachedir: .cache
rootdir: /home/bdolbec/git/toolbelt, inifile: tox.ini
plugins: cov-2.3.1, hypothesis-3.6.0, betamax-0.8.0
collected 164 items 

<snip>

==================================================================================== FAILURES =====================================================================================
_________________________________________________________________ TestPool.test_from_exceptions_populates_a_queue _________________________________________________________________

self = <tests.threaded.test_pool.TestPool testMethod=test_from_exceptions_populates_a_queue>

    def test_from_exceptions_populates_a_queue(self):
        """Ensure a Queue is properly populated from exceptions."""
        urls = ["https://httpbin.org/get?n={0}".format(n) for n in range(5)]
        Exc = pool.ThreadException
        excs = (Exc({'method': 'GET', 'url': url}, None) for url in urls)
    
        job_queue = mock.MagicMock()
        with mock.patch.object(queue, 'Queue', return_value=job_queue):
            with mock.patch.object(thread, 'SessionThread'):
                pool.Pool.from_exceptions(excs)
    
>       assert job_queue.put.call_count == 5
E       AssertionError: assert 0 == 5
E        +  where 0 = <MagicMock name='mock.put' id='139731705948048'>.call_count
E        +    where <MagicMock name='mock.put' id='139731705948048'> = <MagicMock id='139731705990736'>.put

tests/threaded/test_pool.py:69: AssertionError
_________________________________________________________________ TestPool.test_from_urls_constructs_get_requests _________________________________________________________________

self = <tests.threaded.test_pool.TestPool testMethod=test_from_urls_constructs_get_requests>

    def test_from_urls_constructs_get_requests(self):
        """Ensure a Queue is properly populated from an iterable of urls."""
        urls = ["https://httpbin.org/get?n={0}".format(n) for n in range(5)]
    
        job_queue = mock.MagicMock()
        with mock.patch.object(queue, 'Queue', return_value=job_queue):
            with mock.patch.object(thread, 'SessionThread'):
                pool.Pool.from_urls(urls)
    
>       assert job_queue.put.call_count == 5
E       AssertionError: assert 0 == 5
E        +  where 0 = <MagicMock name='mock.put' id='139731697115408'>.call_count
E        +    where <MagicMock name='mock.put' id='139731697115408'> = <MagicMock id='139731705916816'>.put

tests/threaded/test_pool.py:84: AssertionError
___________________________________________________________ TestPool.test_from_urls_constructs_get_requests_with_kwargs ___________________________________________________________

self = <tests.threaded.test_pool.TestPool testMethod=test_from_urls_constructs_get_requests_with_kwargs>

    def test_from_urls_constructs_get_requests_with_kwargs(self):
        """Ensure a Queue is properly populated from an iterable of urls."""
        def merge(*args):
            final = {}
            for d in args:
                final.update(d)
            return final
    
        urls = ["https://httpbin.org/get?n={0}".format(n) for n in range(5)]
    
        kwargs = {'stream': True, 'headers': {'Accept': 'application/json'}}
        job_queue = mock.MagicMock()
        with mock.patch.object(queue, 'Queue', return_value=job_queue):
            with mock.patch.object(thread, 'SessionThread'):
                pool.Pool.from_urls(urls, kwargs)
    
>       assert job_queue.put.call_count == 5
E       AssertionError: assert 0 == 5
E        +  where 0 = <MagicMock name='mock.put' id='139731697115792'>.call_count
E        +    where <MagicMock name='mock.put' id='139731697115792'> = <MagicMock id='139731697155024'>.put

tests/threaded/test_pool.py:106: AssertionError
__________________________________________________________ TestPool.test_get_exception_returns_none_when_queue_is_empty ___________________________________________________________

self = <tests.threaded.test_pool.TestPool testMethod=test_get_exception_returns_none_when_queue_is_empty>

    def test_get_exception_returns_none_when_queue_is_empty(self):
        """Ensure that None is returned when the exception Queue is empty."""
        queues = []
    
        def _side_effect():
            q = mock.MagicMock()
            q.get_nowait.side_effect = queue.Empty()
            queues.append(q)
            return q
    
        with mock.patch.object(queue, 'Queue', side_effect=_side_effect):
            with mock.patch.object(thread, 'SessionThread'):
                p = pool.Pool(None)
    
>       assert len(queues) == 2
E       AssertionError: assert 0 == 2
E        +  where 0 = len([])

tests/threaded/test_pool.py:199: AssertionError
______________________________________________________________ TestPool.test_get_exception_returns_thread_exception _______________________________________________________________

self = <tests.threaded.test_pool.TestPool testMethod=test_get_exception_returns_thread_exception>

    def test_get_exception_returns_thread_exception(self):
        """Ensure that a ThreadException is made when there's data."""
        queues = []
    
        def _side_effect():
            q = mock.MagicMock()
            q.get_nowait.return_value = ({}, None)
            queues.append(q)
            return q
    
        with mock.patch.object(queue, 'Queue', side_effect=_side_effect):
            with mock.patch.object(thread, 'SessionThread'):
                p = pool.Pool(None)
    
>       assert len(queues) == 2
E       AssertionError: assert 0 == 2
E        +  where 0 = len([])

tests/threaded/test_pool.py:161: AssertionError
___________________________________________________________ TestPool.test_get_response_returns_none_when_queue_is_empty ___________________________________________________________

self = <tests.threaded.test_pool.TestPool testMethod=test_get_response_returns_none_when_queue_is_empty>

    def test_get_response_returns_none_when_queue_is_empty(self):
        """Ensure that None is returned when the response Queue is empty."""
        queues = []
    
        def _side_effect():
            q = mock.MagicMock()
            q.get_nowait.side_effect = queue.Empty()
            queues.append(q)
            return q
    
        with mock.patch.object(queue, 'Queue', side_effect=_side_effect):
            with mock.patch.object(thread, 'SessionThread'):
                p = pool.Pool(None)
    
>       assert len(queues) == 2
E       AssertionError: assert 0 == 2
E        +  where 0 = len([])

tests/threaded/test_pool.py:180: AssertionError
_______________________________________________________________ TestPool.test_get_response_returns_thread_response ________________________________________________________________

self = <tests.threaded.test_pool.TestPool testMethod=test_get_response_returns_thread_response>

    def test_get_response_returns_thread_response(self):
        """Ensure that a ThreadResponse is made when there's data."""
        queues = []
    
        def _side_effect():
            q = mock.MagicMock()
            q.get_nowait.return_value = ({}, None)
            queues.append(q)
            return q
    
        with mock.patch.object(queue, 'Queue', side_effect=_side_effect):
            with mock.patch.object(thread, 'SessionThread'):
                p = pool.Pool(None)
    
>       assert len(queues) == 2
E       AssertionError: assert 0 == 2
E        +  where 0 = len([])

tests/threaded/test_pool.py:142: AssertionError
================================================================= 7 failed, 153 passed, 4 skipped in 3.74 seconds =================================================================

dol-sen avatar Mar 08 '18 18:03 dol-sen