testing-cabal / mock

The Python mock library

Home Page:https://docs.python.org/dev/library/unittest.mock.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Version 4.0 release

L1ghtn1ng opened this issue · comments

Hi just am wondering when #476 is going to be merged as this should be a saving grace as MacgicMock in py3.7 does not support being awaitable and this should hopefully fix my issue


self = <tests.discovery.test_githubcode.TestSearchGithubCode object at 0x7f4ade7b1e50>

    async def test_fragments_from_response(self):
        Core.github_key = MagicMock(return_value="lol")
        test_class_instance = githubcode.SearchGithubCode(word="test", limit=500)
>       test_result = await test_class_instance.fragments_from_response(self.OkResponse.response)

tests/discovery/test_githubcode.py:77: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

json_data = <Response [200]>

    @staticmethod
    async def fragments_from_response(json_data: dict) -> List[str]:
>       items: List[Dict[str, Any]] = json_data.get('items') or list()
E       AttributeError: 'Response' object has no attribute 'get'

theHarvester/discovery/githubcode.py:43: AttributeError
___________________________________________________________________________________________________________________________________________________________________________________________________________________ TestSearchGithubCode.test_invalid_fragments_from_response ____________________________________________________________________________________________________________________________________________________________________________________________________________________

self = <tests.discovery.test_githubcode.TestSearchGithubCode object at 0x7f4addc83610>

    async def test_invalid_fragments_from_response(self):
        Core.github_key = MagicMock(return_value="lol")
        test_class_instance = githubcode.SearchGithubCode(word="test", limit=500)
        test_result = test_class_instance.fragments_from_response(self.MalformedResponse.response)
>       assert test_result == []
E       assert <coroutine object SearchGithubCode.fragments_from_response at 0x7f4addc7c320> == []

tests/discovery/test_githubcode.py:84: AssertionError
__________________________________________________________________________________________________________________________________________________________________________________________________________________________ TestSearchGithubCode.test_handle_response_ok __________________________________________________________________________________________________________________________________________________________________________________________________________________________

self = <tests.discovery.test_githubcode.TestSearchGithubCode object at 0x7f4ade4d6ad0>

    async def test_handle_response_ok(self):
        Core.github_key = MagicMock(return_value="lol")
        test_class_instance = githubcode.SearchGithubCode(word="test", limit=500)
        test_result = test_class_instance.handle_response(self.OkResponse.response)
>       assert isinstance(test_result, SuccessResult)
E       assert False
E        +  where False = isinstance(<coroutine object SearchGithubCode.handle_response at 0x7f4addc7c830>, SuccessResult)

tests/discovery/test_githubcode.py:90: AssertionError
________________________________________________________________________________________________________________________________________________________________________________________________________________________ TestSearchGithubCode.test_handle_response_retry _________________________________________________________________________________________________________________________________________________________________________________________________________________________

self = <tests.discovery.test_githubcode.TestSearchGithubCode object at 0x7f4ade4d6890>

    async def test_handle_response_retry(self):
        Core.github_key = MagicMock(return_value="lol")
        test_class_instance = githubcode.SearchGithubCode(word="test", limit=500)
        test_result = test_class_instance.handle_response(self.RetryResponse.response)
>       assert isinstance(test_result, RetryResult)
E       assert False
E        +  where False = isinstance(<coroutine object SearchGithubCode.handle_response at 0x7f4addc7cc20>, RetryResult)

tests/discovery/test_githubcode.py:96: AssertionError
_________________________________________________________________________________________________________________________________________________________________________________________________________________________ TestSearchGithubCode.test_handle_response_fail _________________________________________________________________________________________________________________________________________________________________________________________________________________________

self = <tests.discovery.test_githubcode.TestSearchGithubCode object at 0x7f4addc8b410>

    async def test_handle_response_fail(self):
        Core.github_key = MagicMock(return_value="lol")
        test_class_instance = githubcode.SearchGithubCode(word="test", limit=500)
        test_result = test_class_instance.handle_response(self.FailureResponse.response)
>       assert isinstance(test_result, ErrorResult)
E       assert False
E        +  where False = isinstance(<coroutine object SearchGithubCode.handle_response at 0x7f4addc7ccb0>, ErrorResult)

tests/discovery/test_githubcode.py:102: AssertionError
______________________________________________________________________________________________________________________________________________________________________________________________________________________________ TestSearchGithubCode.test_next_page _______________________________________________________________________________________________________________________________________________________________________________________________________________________________

self = <tests.discovery.test_githubcode.TestSearchGithubCode object at 0x7f4ade4b3410>

    async def test_next_page(self):
        Core.github_key = MagicMock(return_value="lol")
        test_class_instance = githubcode.SearchGithubCode(word="test", limit=500)
        test_result = githubcode.SuccessResult(list(), next_page=2, last_page=4)
>       assert(2 == test_class_instance.next_page_or_end(test_result))
E       assert 2 == <coroutine object SearchGithubCode.next_page_or_end at 0x7f4addc69320>
E        +  where <coroutine object SearchGithubCode.next_page_or_end at 0x7f4addc69320> = <function SearchGithubCode.next_page_or_end at 0x7f4ae1704440>(SuccessResult(fragments=[], next_page=2, last_page=4))
E        +    where <function SearchGithubCode.next_page_or_end at 0x7f4ae1704440> = <theHarvester.discovery.githubcode.SearchGithubCode object at 0x7f4addc259d0>.next_page_or_end

tests/discovery/test_githubcode.py:108: AssertionError
______________________________________________________________________________________________________________________________________________________________________________________________________________________________ TestSearchGithubCode.test_last_page _______________________________________________________________________________________________________________________________________________________________________________________________________________________________

self = <tests.discovery.test_githubcode.TestSearchGithubCode object at 0x7f4addc208d0>

    async def test_last_page(self):
        Core.github_key = MagicMock(return_value="lol")
        test_class_instance = githubcode.SearchGithubCode(word="test", limit=500)
        test_result = githubcode.SuccessResult(list(), None, None)
>       assert(None is test_class_instance.next_page_or_end(test_result))
E       assert None is <coroutine object SearchGithubCode.next_page_or_end at 0x7f4addc697a0>
E        +  where <coroutine object SearchGithubCode.next_page_or_end at 0x7f4addc697a0> = <function SearchGithubCode.next_page_or_end at 0x7f4ae1704440>(SuccessResult(fragments=[], next_page=None, last_page=None))
E        +    where <function SearchGithubCode.next_page_or_end at 0x7f4ae1704440> = <theHarvester.discovery.githubcode.SearchGithubCode object at 0x7f4addc31c50>.next_page_or_end

tests/discovery/test_githubcode.py:114: AssertionError
================================================================================================================================================================================================================================= 7 failed, 11 passed in 17.98s ==================================================================================================================================================================================================================================
sys:1: RuntimeWarning: coroutine 'SearchGithubCode.fragments_from_response' was never awaited
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
sys:1: RuntimeWarning: coroutine 'SearchGithubCode.handle_response' was never awaited
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
sys:1: RuntimeWarning: coroutine 'SearchGithubCode.next_page_or_end' was never awaited
RuntimeWarning: Enable tracemalloc to get the object allocation traceback

Please watch that PR, we don't need any more issues opened about it.

Okay sorry about that just wondering what the ETA is on it? Wish they could backport the 3.8 MagicMock stuff to 3.7 would make a lot of sense

Please just watch the PR.