Skip to content

Tag: python

Mocking async call in python 3.5

How do I mock async call from one native coroutine to other one using unittest.mock.patch? I currently have quite an awkward solution: Then This works but looks ugly. Is there more pythonic way to do this? Answer The solution was actually quite simple: I just needed to convert __call__ method of mock into cor…

PyCharm asks for python interpreter every time project is loaded

Rather frustratingly, every time I load up an existing project or create a new one – it complains there is no interpreter selected and I have to provide the path to it. There is nothing unusual about my python installation, it’s sat in C:/Python27/ as you would expect. It always used to work, but …

How to get form POST input in Tornado?

I amd new to Tornado framework and trying to make a simple form to upload images: I can successfully receive the Posted file using: However I’m unable to receive the alt input. I tried alt = self.request.alt but I get this error and when I use alt = self.request.files[‘alt’], I get: I ran ou…

Logging module not working with Python3

I am having issues with the standard logging module. If I open a python2.7 shell and import logging everything works fine: But if I open a python3.4 shell and import logging I get the following error: I have no idea what the problem is and can’t seem to find anyone else who has had the same issue. Answe…

QtConcurrent in PySide/PyQt

I’m trying to figure out if subclassing QtConcurrent and writing a run method inside it will work: Or is it completely useless? Answer It’s completely useless, because QtConcurrent is a namespace, not a class. Also, neither PyQt nor PySide provide any of the functionality provided by QtConcurrent,…