#4 unchecked access to suite method in test/__init__.py

open
Richard Jones
None
5
2005-10-19
2005-10-19
Zarathushtra
No

Original code in test/__init__.py, line 27 (as of
2005-10-18)

if file.startswith('test_') and file.endswith('.py'):
name = file[5:-3]
test_mods[name] = __import__(file[:-3], globals(),
locals(), [])

Problem:
File "test_gadfly_dbapi20.py" does not define method
suite()

Fixed code:

if file.startswith('test_') and file.endswith('.py'):
name = file[5:-3]
mod = __import__(file[:-3], globals(), locals(), [])
if hasattr(mod, 'suite'): test_mods[name] = mod

Discussion

  • Zarathushtra
    Zarathushtra
    2005-10-19

    • assigned_to: nobody --> richard
     
  • WaffleSouffle
    WaffleSouffle
    2007-04-18

    Logged In: YES
    user_id=1772649
    Originator: NO

    Tried an alternative fix:
    test_gadfly_dbapi20.py

    Line 80 (under def test_ISO8601)
    def suite():
    l = [
    unittest.makeSuite(test_GadflyDBAPI20),
    ]
    return unittest.TestSuite(l)

    This causes the test to be run, but then the tests fail with 5 failures and 6 errors so perhaps these tests aren't intended to be run...