Re: constructor classmethods

2016-11-09 Thread teppo . pera
keskiviikko 9. marraskuuta 2016 2.25.59 UTC Steve D'Aprano kirjoitti: > On Wed, 9 Nov 2016 10:01 am, teppo...@gmail.com wrote: > > > Generally, with testing, it would be optimal to test outputs of the system > > for given inputs without caring how things are implemented. > > I disagree with that

Re: constructor classmethods

2016-11-08 Thread Marko Rauhamaa
Steve D'Aprano : > On Wed, 9 Nov 2016 10:01 am, teppo.p...@gmail.com wrote: >> Generally, with testing, it would be optimal to test outputs of the >> system for given inputs without caring how things are implemented. > > I disagree with that statement. I, OTOH, agree with it. > But in fact, that

Re: constructor classmethods

2016-11-08 Thread Steve D'Aprano
On Wed, 9 Nov 2016 10:01 am, teppo.p...@gmail.com wrote: > Generally, with testing, it would be optimal to test outputs of the system > for given inputs without caring how things are implemented. I disagree with that statement. You are talking about "black-box testing" -- the test code should tr

Re: constructor classmethods

2016-11-08 Thread Chris Angelico
On Wed, Nov 9, 2016 at 10:01 AM, wrote: > One solution is: > > class Example: > def __init__(self, queue=None): > self._queue = queue or Queue() > > Fine approach, but technically __init__ has two execution branches and > someone staring blindly coverages might require covering those

Re: constructor classmethods

2016-11-08 Thread teppo . pera
> How is having 15 arguments in a .create() method better than having 15 > arguments in __init__() ? > So, if you use the create() method, and it sets up internal data structures, > how do you test them? In other words, if create() makes that queue then how > do you test with a half-empty queue

Re: constructor classmethods

2016-11-07 Thread Ethan Furman
On 11/07/2016 12:46 AM, teppo.p...@gmail.com wrote: torstai 3. marraskuuta 2016 14.45.49 UTC Ethan Furman kirjoitti: On 11/03/2016 01:50 AM, teppo wrote: The guide is written in c++ in mind, yet the concepts stands for any programming language really. Read it through and think about it. If

Re: constructor classmethods

2016-11-07 Thread David Palao
>> >> If the class in question has legitimate, non-testing, reasons to specify >> different Queues, then make it a default argument instead: >> >> def __init__(self, ..., queue=None): >> if queue is None: >> queue = Queue() >> self.queue = queue > > I already stated that this is

Re: constructor classmethods

2016-11-07 Thread teppo . pera
torstai 3. marraskuuta 2016 14.47.18 UTC Chris Angelico kirjoitti: > On Thu, Nov 3, 2016 at 7:50 PM, wrote: > > Little bit background related to this topic. It all starts from this > > article: > > http://misko.hevery.com/attachments/Guide-Writing%20Testable%20Code.pdf > > > > The guide is writt

Re: constructor classmethods

2016-11-07 Thread teppo . pera
torstai 3. marraskuuta 2016 14.45.49 UTC Ethan Furman kirjoitti: > On 11/03/2016 01:50 AM, teppo wrote: > > > The guide is written in c++ in mind, yet the concepts stands for any > > programming language really. Read it through and think about it. If > > you come back to this topic and say: "yea

Re: constructor classmethods

2016-11-03 Thread Ethan Furman
On 11/03/2016 07:45 AM, Ethan Furman wrote: On 11/03/2016 01:50 AM, teppo.p...@gmail.com wrote: The guide is written in c++ in mind, yet the concepts stands for any programming language really. Read it through and think about it. If you come back to this topic and say: "yeah, but it's c++", t

Re: constructor classmethods

2016-11-03 Thread Chris Angelico
On Thu, Nov 3, 2016 at 7:50 PM, wrote: > Little bit background related to this topic. It all starts from this article: > http://misko.hevery.com/attachments/Guide-Writing%20Testable%20Code.pdf > > The guide is written in c++ in mind, yet the concepts stands for any > programming language really.

Re: constructor classmethods

2016-11-03 Thread Ethan Furman
On 11/03/2016 01:50 AM, teppo.p...@gmail.com wrote: The guide is written in c++ in mind, yet the concepts stands for any programming language really. Read it through and think about it. If you come back to this topic and say: "yeah, but it's c++", then you haven't understood it. The ideas (

Re: constructor classmethods

2016-11-03 Thread teppo . pera
Hello everyone, I'll step into conversation too as I think it is quite important topic. I'd be the one my collegue calls keen to this practice. Little bit background related to this topic. It all starts from this article: http://misko.hevery.com/attachments/Guide-Writing%20Testable%20Code.pdf Th

Re: constructor classmethods

2016-11-02 Thread Steven D'Aprano
On Thursday 03 November 2016 00:46, stest...@gmail.com wrote: > Hi > > I was hoping to canvas opinion on using classmethods as constructors over > __init__. > > We've got a colleague who is very keen that __init__ methods don't contain > any logic/implementation at all, and if there is any, then

Re: constructor classmethods

2016-11-02 Thread Terry Reedy
On 11/2/2016 9:46 AM, stest...@gmail.com wrote: Hi I was hoping to canvas opinion on using classmethods as constructors over __init__. We've got a colleague who is very keen that __init__ methods don't contain any logic/implementation at all, and if there is any, then it should be moved to a

Re: constructor classmethods

2016-11-02 Thread Ethan Furman
On 11/02/2016 06:46 AM, stest...@gmail.com wrote: I was hoping to canvas opinion on using classmethods as constructors over __init__. We've got a colleague who is very keen that __init__ methods don't contain any logic/implementation at all, and if there is any, then it should be moved to a

Re: constructor classmethods

2016-11-02 Thread breamoreboy
On Wednesday, November 2, 2016 at 1:47:00 PM UTC, stes...@gmail.com wrote: > Hi > > I was hoping to canvas opinion on using classmethods as constructors over > __init__. > > We've got a colleague who is very keen that __init__ methods don't contain > any logic/implementation at all, and if ther

Re: constructor classmethods

2016-11-02 Thread Chris Angelico
On Thu, Nov 3, 2016 at 12:46 AM, wrote: > We've got a colleague who is very keen that __init__ methods don't contain > any logic/implementation at all, and if there is any, then it should be moved > to a create() classmethod. > > I get the underlying principal, and it's one that a strict OOp ap