Re: [Tutor] Do not understand code snippet from "26.8. test — Regression tests package for Python"

2017-04-18 Thread Martin A. Brown
Greetings, >Thank you very much Martin; you filled in a lot of details. I had an >overall understanding of what unittest does, but you have now enhanced >that understanding substantially. Happy to help! I'll introduce you to my little menagerie below! >I'm still iffy on how the mixin class

Re: [Tutor] Do not understand code snippet from "26.8. test — Regression tests package for Python"

2017-04-17 Thread boB Stepp
Ah, Peter, if only I could achieve your understanding and mastery! On Mon, Apr 17, 2017 at 3:37 AM, Peter Otten <__pete...@web.de> wrote: > Perhaps it becomes clearer if we build our own class discovery / method > runner system. Given T as the baseclass for classes that provide foo_...() >

Re: [Tutor] Do not understand code snippet from "26.8. test — Regression tests package for Python"

2017-04-17 Thread boB Stepp
On Sun, Apr 16, 2017 at 11:50 PM, Mats Wichmann wrote: > > You got me thinking as well, as I don't much care for unittest, at least > partly because it forces you to use classes even when it doesn't feel > all that natural. I have looked into pytest multiple times, but have

Re: [Tutor] Do not understand code snippet from "26.8. test — Regression tests package for Python"

2017-04-17 Thread Peter Otten
Peter Otten wrote: > class M: > def foo_one(self): > print(self.__class__.__name__, "one") > def foo_two(self): > print(self.__class__.__name__, "one") Oops, foo_two() should of course print "two", not "one". ___ Tutor

Re: [Tutor] Do not understand code snippet from "26.8. test — Regression tests package for Python"

2017-04-17 Thread Peter Otten
boB Stepp wrote: > It is here that I am struggling. If the mixin class does not inherit > from unittest.TestCase, then how is test_func ever seen? Perhaps it becomes clearer if we build our own class discovery / method runner system. Given T as the baseclass for classes that provide foo_...()

Re: [Tutor] Do not understand code snippet from "26.8. test — Regression tests package for Python"

2017-04-17 Thread Mats Wichmann
On 04/16/2017 10:01 PM, boB Stepp wrote: > OK, between Alan and Martin I think that I see how to make the code > snippet actually test a *function* as the snippet seems to suggest. > Recollect that my original question(s) started: You got me thinking as well, as I don't much care for unittest,

Re: [Tutor] Do not understand code snippet from "26.8. test — Regression tests package for Python"

2017-04-17 Thread Alan Gauld via Tutor
On 17/04/17 05:01, boB Stepp wrote: > Am I missing anything? If not, then why did the code snippet use the > (I believe to be misleading.) class variable approach with "func = > mySuperWhammyFunction" and "self.func(self.arg)"? I suspect it was a slightly broken attempt at reuse in that you can

Re: [Tutor] Do not understand code snippet from "26.8. test — Regression tests package for Python"

2017-04-16 Thread boB Stepp
OK, between Alan and Martin I think that I see how to make the code snippet actually test a *function* as the snippet seems to suggest. Recollect that my original question(s) started: On Sat, Apr 15, 2017 at 6:17 PM, boB Stepp wrote: > In the section > >

Re: [Tutor] Do not understand code snippet from "26.8. test — Regression tests package for Python"

2017-04-16 Thread boB Stepp
Thank you very much Martin; you filled in a lot of details. I had an overall understanding of what unittest does, but you have now enhanced that understanding substantially. I'm still iffy on how the mixin class gets its test method called when this class does not subclass from

Re: [Tutor] Do not understand code snippet from "26.8. test — Regression tests package for Python"

2017-04-16 Thread Martin A. Brown
Greetings boB, >2) The big question: What is the program flow for this program? I >am not seeing the order of execution here. How is the unittest module >handling the execution of this? This is a very good question and one that was (at one time) inobvious to me, as well. When you write a

Re: [Tutor] Do not understand code snippet from "26.8. test — Regression tests package for Python"

2017-04-16 Thread Alan Gauld via Tutor
On 16/04/17 16:21, boB Stepp wrote: > I did this and it indeed works. But how do I use this technique to > unittest the given function? I am just not seeing how to do it with > this with this mixin approach, and I have yet to study mixins, though > apparently I have just now started! I'm not

Re: [Tutor] Do not understand code snippet from "26.8. test — Regression tests package for Python"

2017-04-16 Thread boB Stepp
On Sat, Apr 15, 2017 at 6:31 PM, Alan Gauld via Tutor wrote: > On 16/04/17 00:17, boB Stepp wrote: > >> -- >> #!/usr/bin/env python3 >> >> def mySuperWhammyFunction(any_input): >> return

Re: [Tutor] Do not understand code snippet from "26.8. test — Regression tests package for Python"

2017-04-15 Thread Alan Gauld via Tutor
On 16/04/17 00:17, boB Stepp wrote: > -- > #!/usr/bin/env python3 > > def mySuperWhammyFunction(any_input): > return any_input This is a simple function, its not bound to an object > > import unittest > >

[Tutor] Do not understand code snippet from "26.8. test — Regression tests package for Python"

2017-04-15 Thread boB Stepp
In the section https://docs.python.org/3/library/test.html#writing-unit-tests-for-the-test-package I have been trying to make sense of the given pointer and code snippet: Try to maximize code reuse. On occasion, tests will vary by something as small as what type of input is used. Minimize code