On 8/10/13 4:40 PM, Roy Smith wrote:
In article <f7b24010-f3f4-4e86-b6c4-9ddb503d0...@googlegroups.com>,
Josh English <joshua.r.engl...@gmail.com> wrote:
I am working on a library, and adding one feature broke a seemingly unrelated
feature. As I already had Test Cases written, I decided to try to incorporate
the logging module into my class, and turn on debugging at the logger before
the newly-broken test.
Here is an example script:
[followed by 60 lines of code]
The first thing to do is get this down to some minimal amount of code
that demonstrates the problem.
For example, you drag in the logging module, and do some semi-complex
configuration. Are you SURE your tests are getting run multiple times,
or maybe it's just that they're getting LOGGED multiple times. Tear out
all the logging stuff. Just use a plain print statement.
Roy is right: the problem isn't the tests, it's the logging. You are
calling .addHandler in the SimpleChecker.__init__, then you are
constructing two SimpleCheckers, each of which adds a handler. In the
LoaderTC test, you've only constructed one, adding only one handler, so
the "calling q" line only appears once. Then the NameSpaceTC tests
runs, constructs another SimplerChecker, which adds another handler, so
now there are two. That's why the "calling a" and "calling f" lines
appear twice.
Move your logging configuration to a place that executes only once.
Also, btw, you don't need the "del self.checker" in your tearDown
methods: the test object is destroyed after each test, so any objects it
holds will be released after each test with no special action needed on
your part.
--Ned.
--
http://mail.python.org/mailman/listinfo/python-list