Skip to content

jeremyarr/younit

Repository files navigation

https://cdn.rawgit.com/jeremyarr/younit/2275cf7a/docs/_static/logo_full.png

https://tactile.com.au/jenkins/buildStatus/icon?job=younit1 https://tactile.com.au/badge-server/coverage/younit1

younit is a collection of helpers for the unittest module.

Helpers

I want to Helpers to Use
Test coroutines @asyncio_test
Mock out coroutines AsyncMock(), @asyncio_test
Print the name of a test before running it @test_name
Fail a test if it hangs @set_test_hang_alarm, @clear_test_hang_alarm, or @test_hang_alarm
Close all threads associated with a test @close_all_threads

Get It Now

$ pip install younit

Examples

Testing and mocking coroutines:

class MyTestCase(unittest.TestCase):
    async def async_setUp(self):
        pass

    async def async_tearDown(self):
        pass

    @asyncio_test
    async def test_this(self):
        x = AsyncMock()
        await x()
        x.mock.assert_called_once()

Setting up test hang alarms:

class MyTestCase(unittest.TestCase):
    @set_test_hang_alarm
    def setUp(self):
        pass

    @clear_test_hang_alarm
    def tearDown(self):
        pass

Project Links

License

MIT licensed. See the bundled LICENSE file for more details.