I was about to write a longer response but this the nail on the head. If you can’t construct an object without side-effects, it’s a pain to test. I have class methods like Service.start() that will do all the side-effect-y stuff and initialize the Service class with the results.
Now if I want to test that class, I can inject anything I want. > Am 31.01.2016 um 19:48 schrieb Yann Kaiser <[email protected]>: > > I'd say using a classmethod is rather elegant as it lets you factor out the > requests for awaitables which you'd most likely want to replace in testing. > > On Sun, 31 Jan 2016 at 16:19 Imran Geriskovan <[email protected] > <mailto:[email protected]>> wrote: > Did you mean this? : > > aresult = await someafunc() # Good > aobject = await AClass() # Bad!! > bobject = await somefuncreturningBOjbect() # Good??? > > Interesting. What is the difference? > Is it python's duty to make Bad! style, > anti-patterns impossible? > > I think there is no relation between microblog, > sqlite, etc with the subject.
