Skip to content

Instantly share code, notes, and snippets.

@Sorseg
Created September 9, 2015 00:16

Revisions

  1. @samoylovfp samoylovfp created this gist Sep 9, 2015.
    6 changes: 6 additions & 0 deletions problem.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    async def some_coroutine():
    await another_coroutine()


    async def another_coroutine():
    pass
    23 changes: 23 additions & 0 deletions problem_test.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    from unittest import TestCase, mock, main
    import asyncio

    from problem import some_coroutine


    class Test(TestCase):

    def setUp(self):
    self.loop = asyncio.new_event_loop()
    asyncio.set_event_loop(self.loop)

    @mock.patch('problem.another_coroutine')
    def test_some_coroutine(self, mock_another_coroutine):
    async def run_test():
    await some_coroutine()
    mock_another_coroutine.assert_called_with()

    self.loop.run_until_complete(run_test())


    if __name__ == '__main__':
    main()