Testing hack necessity
It’s not uncommon to hack around a bug in a 3rd-party library
def read(f): reader = betalib.BuggyReader() # Disable lock as in v0.3.0 it causes read() to hang. reader._lock = utils.noop # Wait after read to avoid race condition. res = reader.read(f) time.sleep(1) return res
You want to remove these hacks once the bug is fixed as they can be harder to maintain, slower, and may rely on behaviour not guaranteed by the interface.
As a reminder to remove the hack, I like to add a test that will fail when the bug is fixed:
def test_read_hack_is_needed(): '''If this test fails, look at removing the hack in read()''' proper_result = betalib.BuggyReader().read(TEST_FILE) hacky_result = test_module.read(TEST_FILE) assert proper_result != hacky_result