◐ Shell
clean mode source ↗

Message 187621 - Python tracker

+1 for Ezio's suggestion regarding tests that need the mock module. To simplify backporting you may want to do something like the following in a helper module:

    try:
        import unittest.mock as mock
    except ImportError:
        try:
            import mock
        except ImportError:
            mock = None

Then the individual test files would retrieve the mock attribute from the helper module and check it with the skip decorators in the tests that needed mocks.