On Jul 3, 2007, at 9:59 AM, Heikki Toivonen wrote:

D John Anderson wrote:

On Jul 2, 2007, at 10:36 PM, Heikki Toivonen wrote:
Tests should not rely on assert, and AFAIK they don't. If you see any assert calls in any unit, functional or performance test it is a bug.
The unit test framework provides assertions that work even with -O
(assert* methods on classes that derive from unittest), and func and
perf tests rely on CATS or ad hoc tests.

There is a lot of code in Chandler, which is very useful to run during testing, that use asserts to verify that unexpected results occur. These
checks are done using asserts. And, that's the whole reason asserts
exist and how they are intended to be used.

I think you misread what I wrote. My comment above states they should
not be used in *tests*. In the same message I also commented that they
are used in the main Chandler code. And that is fine.

However, someone mentioned that recorded scripts don't work properly
with -O. Is that true? Could they be made to work with -O?

The recorded scripts use asserts to do verification. This turns out to be very convenient for development, because of our debugging environment. We could implement another assert mechanism that does the same thing assert does and is controlled by some other mechanism/ command line flag besides -O. That didn't seem worth the effort since we already need to use asserts in the testing code and asserts are a well established convention.

Also, it's important to not confuse the debug releases with -O in python. We can run with or without -O in either the debug and release builds. The main thing -O does in Python is turn off asserts (e.g. code that is compiled with __debug__). Some debuggers, e.g. wing, won't even let you debug code with -O.

If the reason you want to do the tests without -O is that you're worried about the side-effects introduced by asserts, then implementing another equivalent assert mechanism to run tests won't avoid side-effects of the same testing code.

John


_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

Open Source Applications Foundation "chandler-dev" mailing list
http://lists.osafoundation.org/mailman/listinfo/chandler-dev

Reply via email to