E
Ethan Metsger
Hi, all.
I apologize for what is perhaps a newb question. I'm in the process of
transitioning our testing framework from Perl to Python. While that alone
probably sets off some red flags, I'm afraid it's what I'm stuck with.
I'm modeling a test with five operations: build, execute, validate,
publish, and clean. The main loop might look something like this:
with Test(...) as t:
t.build()
t.execute()
t.validate()
t.publish()
At each run, I want to output a '.' to denote completion of that test
step. I've been able to do this, sort of, using the following decorator
(edited for brevity):
def report(f):
def new(self):
stat = f(self);
if stat is True:
sys.stdout.write ('.')
else:
...
sys.stdout.flush()
return new
(Each one of the test functions returns True or False depending on its
completion status.)
The problem is that rather than outputting a period after each step is
completed, it outputs all four of them at once. Instead of seeing
progress as it happens, I get it when it's finished, even though I'm
flushing the output buffer.
Any thoughts?
Best,
Ethan ([email protected])
http://uppertank.net/ethanm/
I apologize for what is perhaps a newb question. I'm in the process of
transitioning our testing framework from Perl to Python. While that alone
probably sets off some red flags, I'm afraid it's what I'm stuck with.
I'm modeling a test with five operations: build, execute, validate,
publish, and clean. The main loop might look something like this:
with Test(...) as t:
t.build()
t.execute()
t.validate()
t.publish()
At each run, I want to output a '.' to denote completion of that test
step. I've been able to do this, sort of, using the following decorator
(edited for brevity):
def report(f):
def new(self):
stat = f(self);
if stat is True:
sys.stdout.write ('.')
else:
...
sys.stdout.flush()
return new
(Each one of the test functions returns True or False depending on its
completion status.)
The problem is that rather than outputting a period after each step is
completed, it outputs all four of them at once. Instead of seeing
progress as it happens, I get it when it's finished, even though I'm
flushing the output buffer.
Any thoughts?
Best,
Ethan ([email protected])
http://uppertank.net/ethanm/