On 7/16/19 4:41 PM, boB Stepp wrote:
> Peter Otten, while responding to one of my questions in the past,
> mentioned something in passing that apparently has been mulling around
> in the back of my head. I don't recall his exact words, but he
> essentially said that I should be testing the public
On 16/07/2019 23:41, boB Stepp wrote:
> essentially said that I should be testing the public interface to my
> classes, but not the methods only used internally by the class and not
> meant to be publicly accessible.
I suspect he meant that you should publish the tests for the API
but not neces
Peter Otten, while responding to one of my questions in the past,
mentioned something in passing that apparently has been mulling around
in the back of my head. I don't recall his exact words, but he
essentially said that I should be testing the public interface to my
classes, but not the methods
On Fri, Jan 31, 2014 at 02:03:13PM +, James Chapman wrote:
> On the note of what doesn't need a test...
> The question of coverage always comes up when unit testing is
> mentioned and I read an interesting blog article once about it. It
> basically said: Assume you have 85% coverage on a progr
Thanks Steven!
You've raised a few valid points, mostly that the run_forever method
should be broken up. I like the principle of a method doing just one
thing and for whatever reason I didn't apply that thinking to this
method as it's the master loop (even though it does nothing). So for
starters
On Fri, Jan 31, 2014 at 11:31:49AM +, James Chapman wrote:
> Hello tutors
>
> I've constructed an example which shows a problem I'm having testing a real
> world program and would like to run it past you.
[...]
> class Infinite_Loop_Tutor_Question(object):
> def run_forever(self):
>
Hmm...
Here is an example of how I'm currently trying to test it:
test_tutor_question.py
-
# -*- coding: utf-8 -*-
import unittest
import mock
from tutor_question import Infinite_Loop_Tutor_Question
class Test_Infinite_Loop_Tutor_Question(unittest.TestCase):
def
On Fri, Jan 31, 2014 at 6:31 AM, James Chapman wrote:
> try:
> while self.attribute:
> time.sleep(1)
> except KeyboardInterrupt:
> ...
>
> My unit test could then set the attribute. However I'd still have the
> problem of how I get from the unit test line that fires up the method t
On Fri, Jan 31, 2014 at 01:10:03PM +0100, spir wrote:
> I don't know whether one can interrupt while sleeping
py> from time import sleep
py> sleep(60*60*24*365) # 1 year
Traceback (most recent call last):
File "", line 1, in
KeyboardInterrupt
Yes you can.
--
Steven
___
On 01/31/2014 12:31 PM, James Chapman wrote:
try:
while self.attribute:
time.sleep(1)
except KeyboardInterrupt:
Maybe I'm missing apoint or reasoning wrongly, but I'd rather do:
while self.attribute:
try:
time.sleep(1)
except KeyboardInterrupt:
... or something lik
Hello tutors
I've constructed an example which shows a problem I'm having testing a real
world program and would like to run it past you.
tutor_question.py
--
# -*- coding: utf-8 -*-
import sys
import threading
import time
class Time_Printer(threading.Thread)
By the way, there's a nice book by Kent Beck called "Test Driven
Development by Example" that might be helpful to look at:
http://en.wikipedia.org/wiki/Test-Driven_Development_by_Example
___
Tutor maillist - Tutor@python.org
To unsubscribe or chang
On Sun, Dec 8, 2013 at 8:22 PM, Rafael Knuth wrote:
> Hey there,
>
> I struggle to understand what unit testing specifically means in
> practice and how to actually write unit tests for my code (my gut is
> telling me that it's a fairly important concept to understand).
>
> Over the last few days
On 08/12/13 10:22, Rafael Knuth wrote:
My understanding of unit testing is that I have to embed my code into
a test and then I have to define conditions under which my code is
supposed to fail and pass. Is that assumption correct?
That's correct for any kind of unit testing, not just using the
On Sun, Dec 08, 2013 at 11:22:37AM +0100, Rafael Knuth wrote:
> Hey there,
>
> I struggle to understand what unit testing specifically means in
> practice and how to actually write unit tests for my code (my gut is
> telling me that it's a fairly important concept to understand).
In practice, uni
On 08/12/2013 10:22, Rafael Knuth wrote:
Hey there,
I struggle to understand what unit testing specifically means in
practice and how to actually write unit tests for my code (my gut is
telling me that it's a fairly important concept to understand).
Over the last few days I learned how to write
On 12/08/2013 11:22 AM, Rafael Knuth wrote:
Hey there,
I struggle to understand what unit testing specifically means in
practice and how to actually write unit tests for my code (my gut is
telling me that it's a fairly important concept to understand).
[...]
Hello Rafael,
This post is quite l
On Sun, Dec 8, 2013 at 8:22 PM, Rafael Knuth wrote:
> Hey there,
>
> I struggle to understand what unit testing specifically means in
> practice and how to actually write unit tests for my code (my gut is
> telling me that it's a fairly important concept to understand).
Your gut feeling is right.
Hey there,
I struggle to understand what unit testing specifically means in
practice and how to actually write unit tests for my code (my gut is
telling me that it's a fairly important concept to understand).
Over the last few days I learned how to write and work with classes, I
learned quite a l
;To: Alan Gauld
>Sent: Wednesday, 20 November 2013, 17:44
>Subject: Re: [Tutor] Unit testing individual modules
>
>
>
>Thank you for your comments.
>
>I am trying to import the program file named rball.py, then call/run one of
>the modules
>within rball.py [prin
On 19/11/13 16:06, Patti Scott wrote:
Python 2.4
self-study with Python Programming: An Introduction to Computer Science
by Zelle
I am trying to import a program that has a conditional execution
statement at the end so I can troubleshoot individual modules in the
main() program.
I'm not quite s
Python 2.4
self-study with Python Programming: An Introduction to Computer Science by Zelle
I am trying to import a program that has a conditional execution statement at
the end so I can troubleshoot individual modules in the main() program.
Below is the textbook example program. When I try t
Modulok wrote:
List,
When you create unit tests, do you group tests for a given function
together into one unit test method, or do you prefer to have separate
test methods for every assert statement?
Each test method should test one thing. That doesn't necessarily mean
one assert, but one con
List,
When you create unit tests, do you group tests for a given function
together into one unit test method, or do you prefer to have separate
test methods for every assert statement?
Thanks!
-Modulok-
___
Tutor maillist - Tutor@python.org
To unsubsc
Ah, okay -- both of those options make sense. I'll try my hand at Jan's
first and will report back if I have any problems.
Many thanks as always!
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.or
Serdar Tumgoren wrote:
Hello all,
Does anyone have advice for writing unit tests against variables set by
command-line options?
I have a program I'd like to run in either "debug" or "live" mode, with
various settings associated with each. Below is some pseudo-code that shows
what I'd like to do
Am 18.05.2010 22:49, schrieb Serdar Tumgoren:
Hello all,
Does anyone have advice for writing unit tests against variables set
by command-line options?
I have a program I'd like to run in either "debug" or "live" mode,
with various settings associated with each. Below is some pseudo-code
tha
Hello all,
Does anyone have advice for writing unit tests against variables set by
command-line options?
I have a program I'd like to run in either "debug" or "live" mode, with
various settings associated with each. Below is some pseudo-code that shows
what I'd like to do:
<>
mode = p.parse_args
m...@doctors.net.uk wrote:
Dear All,
Quick UT question. I am working on a CSV processing script. I want to write some tests. The tests will need to read in, manipulate and write out some CSV files.
My instinct is to manually construct some small data files, and consider them
as part of the t
Dear All,
Quick UT question. I am working on a CSV processing script. I want to write
some tests. The tests will need to read in, manipulate and write out some CSV
files.
My instinct is to manually construct some small data files, and consider them
as part of the test suite. The other option
Terry Carroll schrieb:
> You can just use a series of Queues, where each Queue represents the work
> being passed from one thread to the other.
If you want, you can have a look at my threadpool module, which implements
exactly this pattern. It is basically nothing more than an elaborate example o
Okay, I was bored tonight, so I cooked up an illustration.Thanks for that!
Here's an example with five stages. Stage 1 takes a string and fills aninput queue with a series of letters from the string. Stages 2-4 do just
take a letter off its input queue and move it to its output queue. Stage5 ta
On Wed, 28 Jun 2006, Terry Carroll wrote:
> On Wed, 28 Jun 2006, Tino Dai wrote:
>
> > Ok, I think I'm going to back up and explain what I'm am heading towards.
> > I'm working on an app that fire off a bunch of threads. Each one of these
> > threads in connected via queues to another thread in a
On Wed, 28 Jun 2006, Tino Dai wrote:
> Ok, I think I'm going to back up and explain what I'm am heading towards.
> I'm working on an app that fire off a bunch of threads. Each one of these
> threads in connected via queues to another thread in a sequence like a
> chain. And how I tell the next sta
On 6/27/06, Kent Johnson <[EMAIL PROTECTED]> wrote:
Tino Dai wrote:> How I have it now:>> semaA = threading.semaphore()>> class nameA:>def __init__(self):> >>def run(self):
> > semaA.release()>> class nameB:>def __init__(
Then where you create instances of those classes:sema = threading.semaphore()
a = nameA(sema)b = nameB(sema)Maybe you don't even need the semaphore at all: have a look atQueue.Queue, it might do exactly what you need.Ok, I think I'm going to back up and explain what I'm am heading towards. I'm work
Tino Dai schreef:
> How I have it now:
>
> semaA = threading.semaphore()
>
> class nameA:
>def __init__(self):
>
>
>def run(self):
>
> semaA.release()
>
> class nameB:
>def __init__(self):
>
>
>def run(self):
> semaA.acqui
[snip]
> class nameB:
>def __init__(self, sema):
> self.sema = sema
>
>
>def run(self):
> self.semaA.acquire()
>
>
I think here Kent meant self.sema.acquire()
[snip]
___
Tutor maillist - Tutor@python.org
Tino Dai wrote:
> How I have it now:
>
> semaA = threading.semaphore()
>
> class nameA:
>def __init__(self):
>
>
>def run(self):
>
> semaA.release()
>
> class nameB:
>def __init__(self):
>
On 6/27/06, Tino Dai <[EMAIL PROTECTED]> wrote:
On 6/27/06, Kent Johnson <[EMAIL PROTECTED]> wrote:
Tino Dai wrote:> And there is one caveat, I> will have to make a bunch of semaphores global instead of local to the> classes. While I know that there is no hard and fast rule about using> global var
On 6/27/06, Kent Johnson <[EMAIL PROTECTED]> wrote:
Tino Dai wrote:> And there is one caveat, I> will have to make a bunch of semaphores global instead of local to the> classes. While I know that there is no hard and fast rule about using> global variables, where can I find or can somebody tell me
Tino Dai wrote:
> And there is one caveat, I
> will have to make a bunch of semaphores global instead of local to the
> classes. While I know that there is no hard and fast rule about using
> global variables, where can I find or can somebody tell me where I can
> find some guidelines about the
On 6/27/06, Baiju M <[EMAIL PROTECTED]> wrote:
On 6/26/06, Tino Dai <[EMAIL PROTECTED]> wrote:[...]> How would I unit test python GUIsFew weeks back I wrote a small article,may be helpful, so here it is :
http://baijum81.livejournal.com/11598.htmlRegards,Baiju MBaiju, This is extremely useful f
On 6/27/06, Alan Gauld <[EMAIL PROTECTED]> wrote:
> Ok, that leads me to my next question. Currently, I have a class> that I> want to unit test, but it contains a semaphore from another class.> Now, I> could make the semaphore a global variable, or I bring in the other
> class.> One violates "good
On 6/26/06, Tino Dai <[EMAIL PROTECTED]> wrote:
[...]
> How would I unit test python GUIs
Few weeks back I wrote a small article,
may be helpful, so here it is :
http://baijum81.livejournal.com/11598.html
Regards,
Baiju M
___
Tutor maillist - Tutor@py
> Ok, that leads me to my next question. Currently, I have a class
> that I
> want to unit test, but it contains a semaphore from another class.
> Now, I
> could make the semaphore a global variable, or I bring in the other
> class.
> One violates "good" programming principles and the other vio
Regards,
Tino:
I agree with Kent on this. As much as possible, a unit test should test
what it is supposed to do.
> Date: Mon, 26 Jun 2006 15:50:36 -0400
> From: "Tino Dai" <[EMAIL PROTECTED]>
> Subject: Re: [Tutor] Unit testing
> To: "Kent Johnson"
I often write unit tests that do this. In my opinion it is simple and straightforward and effective. Some purists will insist that a unit test shouldn't write the file system or touch a database or use any other external resource, but I think that is silly - if the job of a bit of code is to write
Tino Dai wrote:
> Hey Everybody,
>
> First off, I like to thank Kent, Alan, and Danny for their
> invaluable help. You guys are amazing!
You are welcome!
>I do have some questions about unit testing.
>
>I have a part of the code that writes to the filesystem. Is the
> o
"Tino Dai" <[EMAIL PROTECTED]> writes:
> How do I simulate my queues and other sources of data. In Java, there
> is a program called JMock that you can use to simulate that. Is there
> anything like that in Python or do I roll my own and create the appropriate
> queues with some data in the
Hey Everybody, First off, I like to thank Kent, Alan, and Danny for their invaluable help. You guys are amazing! I do have some questions about unit testing. I have read through the diving into python section about unit testing as well as the documentation from the python docs. While tha
> Suppose I had a function like the following:
#
def y_n(prompt="Answer yes or no"):
while True:
answer = raw_input(prompt)
if answer in ['y', 'Y', 'yes']:
print "You said yes!"
break
elif answer in ['n', 'N', 'no']:
print
On Tue, 18 Apr 2006, Andre Roberge wrote:
> Suppose I had a function like the following:
>
> def y_n(prompt="Answer yes or no"):
>while True:
>answer = raw_input(prompt)
>if answer in ['y', 'Y', 'yes']:
>print "You said yes!"
>break
>elif answe
On Tuesday 18 April 2006 23:34, Andre Roberge wrote:
> Hi all-
>
> Suppose I had a function like the following:
>
> [ function that interacts with the outside world ]
...
> How could I go about to write an automated test for it?
You create a mock for raw_input, put the above code inside a module a
Hi all-
Suppose I had a function like the following:
def y_n(prompt="Answer yes or no"):
while True:
answer = raw_input(prompt)
if answer in ['y', 'Y', 'yes']:
print "You said yes!"
break
elif answer in ['n', 'N', 'no']:
print "You s
55 matches
Mail list logo