[Zope3-dev] test failures with python -O
Jeremy Hylton
jeremy@alum.mit.edu
Thu, 19 Dec 2002 12:11:08 -0500
I tried to run Zope3 tests with python -O. I see three failures that
only occur when running with -O. I investigated one to see how far I
could get: testLocationAsTuple() tests that an assertion fails under
some circumstance. The assert statements aren't executed in -O, so
this test could never work.
I wonder, in general, if it makes sense to write a test that triggers
an assert statement. It seems that an assert is claiming that it is
impossible that a certain invariant not hold. That is, the code
requires that the invariant be maintained and doesn't make any claims
of correctness if the assertion is not true. Thus, a unit test
shouldn't be testing for assertion failures.
Jeremy
======================================================================
ERROR: testFailures (Zope.App.RDB.tests.testDSNParser.TestDSNParser)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/home/jeremy/src/Zope3/lib/python/Zope/App/RDB/tests/testDSNParser.py", line 63, in testFailures
self.assertRaises(AssertionError, parseDSN, None)
File "/usr/local/lib/python2.2/unittest.py", line 273, in failUnlessRaises
apply(callableObj, args, kwargs)
File "/usr/home/jeremy/src/Zope3/lib/python/Zope/App/RDB/ZopeDatabaseAdapter.py", line 122, in parseDSN
dsn = dsn[6:]
TypeError: unsubscriptable object
======================================================================
FAIL: testLocationAsTuple (Zope.App.Traversing.tests.testConvenienceFunctions.Test)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/home/jeremy/src/Zope3/lib/python/Zope/App/Traversing/tests/testConvenienceFunctions.py", line 262, in testLocationAsTuple
self.assertRaises(error_type, lat, value)
File "/usr/local/lib/python2.2/unittest.py", line 279, in failUnlessRaises
raise self.failureException, excName
AssertionError: AssertionError
======================================================================
FAIL: testLocationAsUnicode (Zope.App.Traversing.tests.testConvenienceFunctions.Test)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/home/jeremy/src/Zope3/lib/python/Zope/App/Traversing/tests/testConvenienceFunctions.py", line 273, in testLocationAsUnicode
self.assertRaises(error_type, lau, value)
File "/usr/local/lib/python2.2/unittest.py", line 279, in failUnlessRaises
raise self.failureException, excName
AssertionError: AssertionError