In those early days of Łapka lifetime I’ve came across a pretty solid point which can motivate my whim to not downgrade Python to any earlier vesions. There are also another reasons why I’m so obstinated about using Python 3.6 but more on that later.
Good code requires testing.
During development of Łapka I’m trying to follow TDD which requires tests to be written before any production code. Testing Goat is looking on my hands and keyboard all the time and disobeying it’s rules may (and potentially, will be) harmful for the entire project.
And here’s where I came across that filthy bug which took me an hour or two out of my life.
I needed to use unittest.mock in order to fake making a HTTP request to a remote server. My code is using an asynchronous context manager for that and I was having a suspicious looking exception while mocking an object which is relying on this concept.
The very next day, after I gave up using
unittest.mock module in this
scenario, I came across this issue on
the official Python bug tracker. This is the very same issue I was facing a
dozen of hours before. Great. At least now I know it wasn’t me who was silly.
Of course I’ve made walk around but this code might have looked cleaner and be easier to write. However a bird in the hand is worth two in the bush, as they say.
Another strange behaviour is that I can’t use
path.object function (from
unittest.mock module, of course) as a decorator because it is giving me
some more funny exceptions. This is due to its a lack of support of coroutine
functions, I believe.