Re: [gdal-dev] Intermittent failure with Python mocks

2023-04-14 Thread Jon Morris
. From: Sean Gillies Sent: Thursday, April 13, 2023 3:14 PM To: Jon Morris Cc: gdal dev Subject: Re: [gdal-dev] Intermittent failure with Python mocks CAUTION: This email originated from outside of JBA and contains one or more links and one or more attachments. DO NOT click links or open

Re: [gdal-dev] Intermittent failure with Python mocks

2023-04-13 Thread Sean Gillies
Hi Jon, The number one gotcha with patching is documented here https://docs.python.org/3/library/unittest.mock.html#where-to-patch. In a nutshell, you have to patch your own module. I see you're patching gdal in your tests. Patching gdal from your test doesn't do anything, it's too late. Hope

[gdal-dev] Intermittent failure with Python mocks

2023-04-13 Thread Jon Morris
I'm getting intermittent fails with our Python unit tests and I wondered if anyone has seen the same issue. I think it's a race condition where a mock patch is either not applied at all or maybe applied too slowly so the patched function still has its original return value. It might be a pytest